You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
(544) |
May
(1715) |
Jun
(1059) |
Jul
(886) |
Aug
(1214) |
Sep
(1375) |
Oct
(1664) |
Nov
(1153) |
Dec
(1084) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(1630) |
Feb
(1634) |
Mar
(1979) |
Apr
(1119) |
May
(1850) |
Jun
(1231) |
Jul
(1168) |
Aug
(1840) |
Sep
(1038) |
Oct
(1127) |
Nov
(1458) |
Dec
(854) |
2004 |
Jan
(1145) |
Feb
(1064) |
Mar
(2242) |
Apr
(1728) |
May
(1346) |
Jun
(1280) |
Jul
(1681) |
Aug
(2388) |
Sep
(2233) |
Oct
(3246) |
Nov
(3248) |
Dec
(1775) |
2005 |
Jan
(3407) |
Feb
(3049) |
Mar
(2402) |
Apr
(3687) |
May
(3289) |
Jun
(5731) |
Jul
(3905) |
Aug
(5843) |
Sep
(5149) |
Oct
(6866) |
Nov
(4051) |
Dec
(4646) |
2006 |
Jan
(7356) |
Feb
(4713) |
Mar
(9447) |
Apr
(6553) |
May
(6206) |
Jun
(4301) |
Jul
(1160) |
Aug
(23) |
Sep
(11) |
Oct
(19) |
Nov
(26) |
Dec
(15) |
2007 |
Jan
(28) |
Feb
(24) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Heiko W. R. <hw...@pi...> - 2006-07-10 14:37:42
|
User: pilhuhn Date: 06/07/10 10:37:39 Modified: varia/src/main/org/jboss/jmx/adaptor/snmp/agent Tag: Branch_4_0 ReadOnlyException.java RequestHandlerImpl.java Added: varia/src/main/org/jboss/jmx/adaptor/snmp/agent Tag: Branch_4_0 ComparableSnmpObjectId.java Log: Handle oid sorting and comparing through a ComparableSnmpObjectId-Class. With use of it, fix JBAS-3178. Revision Changes Path No revision No revision 1.1.2.8 +8 -1 contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/ReadOnlyException.java (In the diff below, changes in quantity of whitespace are not shown.) Index: ReadOnlyException.java =================================================================== RCS file: /cvsroot/jboss/contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/ReadOnlyException.java,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -b -r1.1.2.7 -r1.1.2.8 --- ReadOnlyException.java 30 May 2006 19:31:12 -0000 1.1.2.7 +++ ReadOnlyException.java 10 Jul 2006 14:37:39 -0000 1.1.2.8 @@ -21,6 +21,8 @@ */ package org.jboss.jmx.adaptor.snmp.agent; +import org.opennms.protocols.snmp.SnmpObjectId; + /** * This exception is thrown when an entry is read only and * a client wants to write to it. @@ -34,4 +36,9 @@ { super("OID " + oid + " is read only"); } + + public ReadOnlyException(SnmpObjectId oid) + { + super("OID " + oid + " is read only"); + } } 1.1.2.2 +198 -198 contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java (In the diff below, changes in quantity of whitespace are not shown.) Index: RequestHandlerImpl.java =================================================================== RCS file: /cvsroot/jboss/contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -b -r1.1.2.1 -r1.1.2.2 --- RequestHandlerImpl.java 6 May 2006 22:48:00 -0000 1.1.2.1 +++ RequestHandlerImpl.java 10 Jul 2006 14:37:39 -0000 1.1.2.2 @@ -25,9 +25,10 @@ import java.net.InetAddress; import java.util.Iterator; import java.util.List; -import java.util.Set; import java.util.SortedMap; +import java.util.SortedSet; import java.util.TreeMap; +import java.util.TreeSet; import javax.management.Attribute; import javax.management.MBeanServer; @@ -57,7 +58,7 @@ * * @author <a href="mailto:hw...@pi...>">Heiko W. Rupp</a> * @author <a href="mailto:dim...@jb...">Dimitris Andreadis</a> - * @version $Revision: 1.1.2.1 $ + * @version $Revision: 1.1.2.2 $ */ public class RequestHandlerImpl extends RequestHandlerSupport implements Reconfigurable @@ -67,9 +68,12 @@ private static final String NO_ENTRY_FOUND_FOR_OID = "No entry found for oid "; private static final String SKIP_ENTRY = " - skipping entry"; + /** Bindings from oid to mbean */ protected SortedMap bindings = new TreeMap(); + private SortedSet oidKeys = null; + /** Has this RequestHandler instance been initialized? */ private boolean initialized = false; @@ -80,7 +84,8 @@ */ public RequestHandlerImpl() { - // empty + bindings = new TreeMap(); + oidKeys = new TreeSet(); } // RequestHandler Implementation --------------------------------- @@ -96,8 +101,8 @@ public void initialize(String resourceName, MBeanServer server, Logger log, Clock uptime) throws Exception { + log.debug("initialize() with res=" + resourceName); super.initialize(resourceName, server, log, uptime); - log.debug("initialized() with res=" + resourceName); if (resourceName != null) initializeBindings(); else @@ -147,6 +152,8 @@ */ public SnmpPduRequest snmpReceivedGet(SnmpPduPacket pdu, boolean getNext) { + try + { SnmpPduRequest response = null; int pduLength = pdu.getLength(); final boolean trace = log.isTraceEnabled(); @@ -169,30 +176,33 @@ { /* * We call getNextOid() to find out what is the next valid OID - * instance in the supported MIB (sub-)tree. Assign that OID to - * the VB List and then proceed same as that of get request. If - * the passed oid is already the last, we flag it. - */ - String oids = oid.toString(); - try + * instance in the supported MIB (sub-)tree. Assign that OID to the + * VB List and then proceed same as that of get request. If the + * passed oid is already the last, we flag it. + */ + ComparableSnmpObjectId coid = new ComparableSnmpObjectId(oid); + oid = getNextOid(coid, true); + if (oid == null) { - oids = getNextOid(oid.toString()); - oid = new SnmpObjectId(oids); - pdu.setVarBindAt(i, new SnmpVarBind(oid)); + good = false; } - catch (NoSuchFieldException nse) - { // abused - good = false; // no next oid found + else + { + pdu.setVarBindAt(i, new SnmpVarBind(oid)); } } + if (oid!=null) vblist[i] = new SnmpVarBind(oid); + else + vblist[i] = new SnmpVarBind(vb.getName()); // oid passed in + if (trace) - log.trace("oid=" + oid.toString()); + log.trace("oid=" + oid); SnmpSyntax result = null; - if (bindings != null) - result = getValueFor(oid.toString()); + if (good && bindings != null) + result = getValueFor(oid); if (trace) log.trace("got result of " + result); @@ -201,7 +211,7 @@ { errorStatus = SnmpPduPacket.ErrNoSuchName; errorIndex = i + 1; - // log.debug("Error Occured " + vb.getName().toString()); + log.debug("Error Occured " + vb.getName().toString()); } else { @@ -210,11 +220,17 @@ + vblist[i].getName().toString()); log.debug(" --> " + vblist[i].getValue().toString()); } - } + } // for ... response = new SnmpPduRequest(SnmpPduPacket.RESPONSE, vblist); response.setErrorStatus(errorStatus); response.setErrorIndex(errorIndex); return response; + } catch (Exception e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } } /** @@ -250,7 +266,7 @@ SnmpSyntax result = null; try { - result = setValueFor(oid.toString(),newVal); + result = setValueFor(oid,newVal); } catch (ReadOnlyException e) { @@ -389,8 +405,10 @@ return; } log.debug("Found " + mappings.size() + " attribute mappings"); + /** + * We have the MBeans now. Put them into the bindungs. + */ - // Turn the parsed mappings into bindings. Iterator it = mappings.iterator(); while (it.hasNext()) { @@ -410,11 +428,11 @@ BindEntry be = new BindEntry(oid, mmb.getName(), ma.getName()); be.isReadWrite = ma.isReadWrite(); + ComparableSnmpObjectId coid = new ComparableSnmpObjectId(oid); + if (log.isTraceEnabled()) log.trace("New bind entry " + be); - - if (bindings.containsKey(oid)) - { + if (bindings.containsKey(coid)) { log.info("Duplicate oid " + oid + SKIP_ENTRY); continue; } @@ -428,7 +446,9 @@ log.info("Invalid attribute name " + ma.getName() + " for oid " + oid + SKIP_ENTRY); continue; } - bindings.put(oid, be); + bindings.put(coid, be); + oidKeys.add(coid); + } } } @@ -440,8 +460,8 @@ * The oid we want a value for * @return SnmpNull if no value present */ - private SnmpSyntax getValueFor(final String oid) - { + private SnmpSyntax getValueFor(final SnmpObjectId oid) { + BindEntry be = findBindEntryForOid(oid); SnmpSyntax ssy = null; if (be != null) @@ -496,7 +516,7 @@ * @return null on success, non-null on failure * @throws ReadOnlyException If the referred entry is read only. */ - private SnmpSyntax setValueFor(final String oid, final SnmpSyntax newVal) throws ReadOnlyException + private SnmpSyntax setValueFor(final SnmpObjectId oid, final SnmpSyntax newVal) throws ReadOnlyException { final boolean trace = log.isTraceEnabled(); @@ -563,111 +583,88 @@ return ssy; } + /** * Lookup a BinEntry on the given oid. If the oid ends in .0, * then the .0 will be stripped of before the search. * @param oid The oid look up. * @return a bind entry or null. */ - private BindEntry findBindEntryForOid(final String oid) + private BindEntry findBindEntryForOid(final SnmpObjectId oid) { + + ComparableSnmpObjectId coid= new ComparableSnmpObjectId(oid); + + if (coid.isLeaf()) { - String localOid = oid; - if (oid.endsWith(".0")) - localOid = oid.substring(0,oid.length()-2); + coid = coid.removeLastPart(); + } + BindEntry be = (BindEntry)bindings.get(coid); - BindEntry be = (BindEntry) bindings.get(localOid); return be; } /** - * Tries to retrieve the next oid following the current one - * - * @param in - * an oid - * @return an oid - * @throws NoSuchFieldException - * if no next oid can be found - */ - private String getNextOid(final String in) throws NoSuchFieldException - { - final boolean trace = log.isTraceEnabled(); + * Return the next oid that is larger than ours. + * @param oid the starting oid + * @param stayInSubtree if true, the next oid will not have a different prefix than the one of oid. + * @return the next oid or null if none found. + */ + private ComparableSnmpObjectId getNextOid(final ComparableSnmpObjectId oid, boolean stayInSubtree) { + ComparableSnmpObjectId coid = new ComparableSnmpObjectId(oid); + + + if (coid.isLeaf()) + coid = coid.removeLastPart(); + + SortedSet ret; + ret= oidKeys.tailSet(oid); // get oids >= oid + Iterator it = ret.iterator(); + ComparableSnmpObjectId roid=null; - String roid = in.substring(0, in.lastIndexOf('.')); - - if (trace) - log.trace("in: " + in + " roi: " + roid); - - Set oids = bindings.keySet(); - Iterator it = oids.iterator(); - while (it.hasNext()) + /* + * If there are elements in the tail set, then + * - get first one. + * - if first is input (which it is supposed to be according to the contract of + * SortedSet.tailSet() , then get next, which is the + * one we look for. + */ + if (it.hasNext()) { - String id = (String) it.next(); - int comp = compareOid(in, id); - if (trace) - log.trace("--- found id " + id + " comp = " + comp); - - if (comp >= 0) - continue; - - if (trace) - log.trace("Returning " + id); - - return id; + roid = (ComparableSnmpObjectId)it.next(); // oid } - if (trace) - log.trace("## no next oid found for " + in); - throw new NoSuchFieldException(); + if (roid == null) + { + return null; // roid is null, } - /** - * Compare the two passed oid-strings. - * - * @param oid1 - * @param oid2 - * @return 0 when equal, 1 if oid2 > oid1 and -1 if oid1>oid2 - */ - private int compareOid(final String oid1, final String oid2) + if (roid.compareTo(coid)==0) // input elment { - int res; - int nd1 = countDots(oid1); - int nd2 = countDots(oid2); - res = nd1 - nd2; - if (res != 0) // different number of dots -> not equal - return res; - - // equal number of dots. Check for same prefix (subtree) - String tpref = oid1.substring(0, oid1.lastIndexOf(".")); - String opref = oid2.substring(0, oid2.lastIndexOf(".")); - - res = tpref.compareTo(opref); - - // same prefix - if (res == 0) + // if there is a next element, then it is ours. + if (it.hasNext()) { - String tsuf = oid1.substring(oid1.lastIndexOf(".") + 1); - String osuf = oid2.substring(oid2.lastIndexOf(".") + 1); - int tval = Integer.parseInt(tsuf); - int oval = Integer.parseInt(osuf); - - res = tval - oval; + roid = (ComparableSnmpObjectId)it.next(); + } + else + { + roid = null; // end of list } - return res; } - /** - * Count the number of dots in the passed String (an oid actually) + /* + * Check if still in subtree if requested to stay within */ - private int countDots(final String in) + if (stayInSubtree && roid != null) { - int count = 0; - for (int i = 0; i < in.length(); i++) - if (in.charAt(i) == '.') - count++; + ComparableSnmpObjectId parent = coid.removeLastPart(); + if (!parent.isRootOf(roid)) + roid = null; + } - return count; + return roid; } + // Inner Class --------------------------------------------------- /** @@ -675,10 +672,9 @@ * * @author <a href="mailto:pi...@us...>">Heiko W. Rupp</a> */ - private class BindEntry implements Comparable - { - private final String oid; - private final int numDots; + private class BindEntry implements Comparable { + private final ComparableSnmpObjectId oid; + private ObjectName mbean; private Attribute attr; private String mName; @@ -695,10 +691,20 @@ * @param attrName * The name of the attribute to query */ - BindEntry(final String oid, final String mbName, final String attrName) - { - this.oid = oid; - numDots = countDots(oid); + BindEntry(final String oidString, final String mbName, final String attrName) { + this(new ComparableSnmpObjectId(oidString), + mbName, + attrName); + } + + /** + * Constructs a new BindEntry. + * @param coid The SNMP-oid, this entry will use. + * @param mbName The name of an MBean with attribute to query + * @param attrName The name of the attribute to query + */ + BindEntry(final ComparableSnmpObjectId coid, final String mbName, final String attrName) { + oid = coid; this.mName = mbName; this.aName = attrName; try @@ -715,8 +721,21 @@ } } - public Attribute getAttr() - { + /** + * A string representation of this BindEntry + */ + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append("[oid="); + buf.append(oid).append(", mbean="); + buf.append(mName).append(", attr="); + buf.append(aName).append(", rw="); + buf.append(isReadWrite).append("]"); + + return buf.toString(); + } + + public Attribute getAttr() { return attr; } @@ -725,17 +744,12 @@ return mbean; } - public String getOid() + public ComparableSnmpObjectId getOid() { return oid; } - public int getNumDots() - { - return numDots; - } - /** * Compare two BindEntries. Ordering is defined at oid-level. * @@ -759,24 +773,10 @@ if (getOid().equals(obe.getOid())) return 0; - int res = compareOid(oid, obe.getOid()); + int res =oid.compare(obe.getOid()); return res; } - /** - * A string representation of this BindEntry - */ - public String toString() - { - StringBuffer buf = new StringBuffer(); - buf.append("[oid="); - buf.append(oid).append(", mbean="); - buf.append(mName).append(", attr="); - buf.append(aName).append(", rw="); - buf.append(isReadWrite).append("]"); - - return buf.toString(); - } } } No revision No revision 1.1.2.2 +139 -0 contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/ComparableSnmpObjectId.java (In the diff below, changes in quantity of whitespace are not shown.) Index: ComparableSnmpObjectId.java =================================================================== RCS file: ComparableSnmpObjectId.java diff -N ComparableSnmpObjectId.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ComparableSnmpObjectId.java 10 Jul 2006 14:37:39 -0000 1.1.2.2 @@ -0,0 +1,139 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.jmx.adaptor.snmp.agent; + +import org.opennms.protocols.snmp.SnmpObjectId; + +/** + * Provide SnmpObjectIds that are Comparable to be used + * in SortedSets etc. + * @author <a href="mailto:hw...@pi...">Heiko W. Rupp</a> + * @version $Revision: 1.1.2.2 $ + */ +public class ComparableSnmpObjectId extends SnmpObjectId implements Comparable +{ + + public ComparableSnmpObjectId(String oid) + { + super(oid); + } + + public ComparableSnmpObjectId(SnmpObjectId oid) + { + super(oid); + } + + public ComparableSnmpObjectId(int[] identifiers) + { + super(identifiers); + } + + /** + * Compare to the passed object. Uses compare() + * from the underlying snmp-library + * @see SnmpObjectId.compare() + * @param o Object to compare with (Usually a ComparableSnmpObjectId) + * @return -1, if no SnmpObjectId passed in, the result of the underlying compare otherwise. + */ + public int compareTo(Object o) + { + + if (o==null) + return -1; + + if (!(o instanceof SnmpObjectId)) + return -1; + + return this.compare((SnmpObjectId)o); + } + + /** + * This object is a leaf if the last part of the oid parts is a 0 (Zero) + * @return true if the oid ends in 0 + */ + public boolean isLeaf() + { + int[] ids = getIdentifiers(); + if (ids.length==0) { // no data present (should not happen) + return false; + } + if (ids[ids.length-1]==0) + { + return true; + } + return false; + } + + /** + * Removes the last oid-component. + * Example .1.2.3.4.0 as input yields .1.2.3.4 as output + * @return an oid with the last part removed. + */ + public ComparableSnmpObjectId removeLastPart() + { + int[] ids = getIdentifiers(); + + int[] outs = new int[ids.length-1]; + int len = ids.length-1; + for (int i = 0; i<len ; i++) + { + outs[i]=ids[i]; + } + ComparableSnmpObjectId out = new ComparableSnmpObjectId(outs); + return out; + } + + /** + * Build an oid where the second last component + * (after removing a .0 of a leaf) is increased by 1. + * The last component is removed, to the result actually forms + * the root of a subtree, that is adjacent to the subtree this + * object is in. + * Example .1.2.3.4.0 -> .1.2.4 + * Example .1.2.3.4.5 -> .1.2.4 + * @return + */ + public ComparableSnmpObjectId getNextArc() + { + ComparableSnmpObjectId cid = this; + if (isLeaf()) + { + cid = removeLastPart(); + } + cid = cid.removeLastPart(); + + int[] ids = cid.getIdentifiers(); + int[] ods = new int[ids.length]; + System.arraycopy(ids, + 0, + ods, + 0, + ids.length); + + int len = ods.length-1; + ods[len]++; + + ComparableSnmpObjectId ret = new ComparableSnmpObjectId(ods); + return ret; + } + +} |
From: Heiko W. R. <hw...@pi...> - 2006-07-10 14:23:56
|
User: pilhuhn Date: 06/07/10 10:23:54 Modified: src/bin twiddle.sh twiddle.bat Log: Include jboss-common.jar to make tiddle work again. JBAS-3382. Revision Changes Path 1.9 +2 -1 jboss-console/src/bin/twiddle.sh (In the diff below, changes in quantity of whitespace are not shown.) Index: twiddle.sh =================================================================== RCS file: /cvsroot/jboss/jboss-console/src/bin/twiddle.sh,v retrieving revision 1.8 retrieving revision 1.9 diff -u -b -r1.8 -r1.9 --- twiddle.sh 21 Jun 2005 11:42:13 -0000 1.8 +++ twiddle.sh 10 Jul 2006 14:23:54 -0000 1.9 @@ -5,7 +5,7 @@ ## ## ### ====================================================================== ### -### $Id: twiddle.sh,v 1.8 2005/06/21 11:42:13 dimitris Exp $ ### +### $Id: twiddle.sh,v 1.9 2006/07/10 14:23:54 pilhuhn Exp $ ### DIRNAME=`dirname $0` PROGNAME=`basename $0` @@ -54,6 +54,7 @@ if [ "x$JBOSS_CLASSPATH" = "x" ]; then JBOSS_CLASSPATH="$JBOSS_BOOT_CLASSPATH" JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_HOME/client/jbossall-client.jar" + JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_HOME/client/jboss-common.jar" JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_HOME/client/getopt.jar" JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_HOME/client/log4j.jar" JBOSS_CLASSPATH="$JBOSS_CLASSPATH:$JBOSS_HOME/lib/jboss-jmx.jar" 1.10 +2 -1 jboss-console/src/bin/twiddle.bat (In the diff below, changes in quantity of whitespace are not shown.) Index: twiddle.bat =================================================================== RCS file: /cvsroot/jboss/jboss-console/src/bin/twiddle.bat,v retrieving revision 1.9 retrieving revision 1.10 diff -u -b -r1.9 -r1.10 --- twiddle.bat 21 Jun 2005 11:42:13 -0000 1.9 +++ twiddle.bat 10 Jul 2006 14:23:54 -0000 1.10 @@ -3,7 +3,7 @@ rem JBoss JVM Launcher rem ------------------------------------------------------------------------- -rem $Id: twiddle.bat,v 1.9 2005/06/21 11:42:13 dimitris Exp $ +rem $Id: twiddle.bat,v 1.10 2006/07/10 14:23:54 pilhuhn Exp $ if not "%ECHO%" == "" echo %ECHO% if "%OS%" == "Windows_NT" setlocal @@ -54,6 +54,7 @@ rem JBOSS_CLASSPATH was not yet set if not "%JBOSS_CLASSPATH%" == "" GOTO HAVE_JB_CP set JBOSS_CLASSPATH=%DIRNAME%\..\client\jbossall-client.jar +set JBOSS_CLASSPATH=%JBOSS_CLASSPATH%;%DIRNAME%\..\client\jboss-common.jar set JBOSS_CLASSPATH=%JBOSS_CLASSPATH%;%DIRNAME%\..\client\getopt.jar set JBOSS_CLASSPATH=%JBOSS_CLASSPATH%;%DIRNAME%\..\client\log4j.jar set JBOSS_CLASSPATH=%JBOSS_CLASSPATH%;%DIRNAME%\..\lib\jboss-jmx.jar |
From: Heiko W. R. <hw...@pi...> - 2006-07-10 14:16:12
|
User: pilhuhn Date: 06/07/10 10:16:11 Added: src/main/org/jboss/test/snmp ComparableSnmpOidTestCase.java Log: Unit Test for the ComparableSnmoObjectId. JBAS-3178. Revision Changes Path 1.1 date: 2006/07/10 14:16:11; author: pilhuhn; state: Exp;jbosstest/src/main/org/jboss/test/snmp/ComparableSnmpOidTestCase.java Index: ComparableSnmpOidTestCase.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.snmp; import java.util.SortedSet; import java.util.TreeSet; import org.jboss.jmx.adaptor.snmp.agent.ComparableSnmpObjectId; import junit.framework.TestCase; /** * Tests for the ComparableSnmpObjectId, a Subclass of SnmpObjectId from * the joesnmp package. Most tests are trivial. * @author <a href="mailto:hw...@pi...">Heiko W. Rupp</a> * @version $Revision: 1.1 $ */ public class ComparableSnmpOidTestCase extends TestCase { /** * Make sure, that the passed oid which does not end in .0 * is not detected as leaf. */ public void testIsNotLeaf() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId(".1.2.3.4"); boolean res = coid.isLeaf(); assertFalse(res); } /** * Make sure that the passed oid ending in .0 is detected as leaf. */ public void testIsLeaf() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId(".1.2.3.4.0"); boolean res = coid.isLeaf(); assertTrue(res); } /** * Make sure that the passed oid ending in .0 is detected as leaf. */ public void testIsLeaf2() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId("1.2.3.4.0"); boolean res = coid.isLeaf(); assertTrue(res); } /** * See if the last part of an oid is correctly chopped of. * */ public void testRemoveLastPart() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId("1.2.3.4.0"); ComparableSnmpObjectId res = coid.removeLastPart(); assertEquals(".1.2.3.4",res.toString()); } /** * See if compareTo from Comparable works as expected. * This is needed for use of the ComparableSnmpObjectId in SortedSets etc. * @see java.lang.Comparable */ public void testCompareTo1() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId("1.2.3.4.0"); ComparableSnmpObjectId coid2 = new ComparableSnmpObjectId(".1.2.3.4.0"); int res = coid.compareTo(coid2); assertEquals(0,res); } /** * See if compareTo from Comparable works as expected. * This is needed for use of the ComparableSnmpObjectId in SortedSets etc. * @see java.lang.Comparable */ public void testCompareTo2() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId("1.2.3.4"); ComparableSnmpObjectId coid2 = new ComparableSnmpObjectId("1.2.3.4.0"); int res = coid.compareTo(coid2); assertTrue(res!=0); } /** * See if compareTo from Comparable works as expected. * This is needed for use of the ComparableSnmpObjectId in SortedSets etc. * @see java.lang.Comparable */ public void testCompareTo3() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId("1.2.3.4.1"); ComparableSnmpObjectId coid2 = new ComparableSnmpObjectId("1.2.3.4.2"); int res = coid.compareTo(coid2); assertTrue(res<0); } /** * See if compareTo from Comparable works as expected. * This is needed for use of the ComparableSnmpObjectId in SortedSets etc. * @see java.lang.Comparable */ public void testCompareTo4() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId("1.2.3.4.2"); ComparableSnmpObjectId coid2 = new ComparableSnmpObjectId("1.2.3.4.1"); int res = coid.compareTo(coid2); assertTrue(res>0); } /** * See if compareTo from Comparable works as expected. * This is needed for use of the ComparableSnmpObjectId in SortedSets etc. * @see java.lang.Comparable */ public void testCompareTo5() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId("1.2.3.4.2"); Object coid2 = new Object(); int res = coid.compareTo(coid2); assertTrue(res == -1); } public void testGetNextArc() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId("1.2.3.4"); ComparableSnmpObjectId res = coid.getNextArc(); assertEquals(".1.2.4",res.toString()); } public void testGetNextArc2() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId(".1.2.3.4.5"); ComparableSnmpObjectId res = coid.getNextArc(); assertEquals(".1.2.3.5",res.toString()); } public void testGetNextArc3() { ComparableSnmpObjectId coid = new ComparableSnmpObjectId(".1.2.3.4.0"); ComparableSnmpObjectId res = coid.getNextArc(); assertEquals(".1.2.4",res.toString()); } public void testGetSubtree() { SortedSet s = new TreeSet(); ComparableSnmpObjectId coid = new ComparableSnmpObjectId("1.2.3.4.0"); s.add(coid); coid = new ComparableSnmpObjectId("1.2.3.5.0"); s.add(coid); coid = new ComparableSnmpObjectId("1.2.3.6.0"); s.add(coid); ComparableSnmpObjectId c2 = new ComparableSnmpObjectId("1.2.3.4.1"); SortedSet subset = s.tailSet(c2); assertEquals(2,subset.size()); subset = s.headSet(c2); assertEquals(1,subset.size()); } } |
From: Heiko W. R. <hw...@pi...> - 2006-07-10 14:16:11
|
User: pilhuhn Date: 06/07/10 10:16:08 Log: Directory /cvsroot/jboss/jbosstest/src/main/org/jboss/test/snmp added to the repository |
From: Heiko W. R. <hw...@pi...> - 2006-07-10 14:15:33
|
User: pilhuhn Date: 06/07/10 10:15:29 Modified: varia/src/resources/services/snmp/deploy attributes.xml Log: Finally SNMP-nodes can have an index larger than 9. See JBAS-3178. Revision Changes Path 1.4 +2 -1 contrib/varia/src/resources/services/snmp/deploy/attributes.xml (In the diff below, changes in quantity of whitespace are not shown.) Index: attributes.xml =================================================================== RCS file: /cvsroot/jboss/contrib/varia/src/resources/services/snmp/deploy/attributes.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- attributes.xml 7 May 2006 16:40:42 -0000 1.3 +++ attributes.xml 10 Jul 2006 14:15:29 -0000 1.4 @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!-- - $Id: attributes.xml,v 1.3 2006/05/07 16:40:42 dimitris Exp $ + $Id: attributes.xml,v 1.4 2006/07/10 14:15:29 pilhuhn Exp $ This configuration file controls the mapping of JMX mbean attributes to SNMP OIDs accessible through the snmp-adapter. @@ -37,6 +37,7 @@ <!-- DefaultDS statistics --> <mbean name="jboss.jca:name=DefaultDS,service=ManagedConnectionPool" oid-prefix=".1.2.3.4.1"> <attribute name="InUseConnectionCount" oid=".9"/> + <attribute name="MaxConnectionsInUseCount" oid=".10"/> </mbean> <!-- system information group see RFC-1213 --> |
From: Heiko W. R. <hw...@pi...> - 2006-07-10 14:14:44
|
User: pilhuhn Date: 06/07/10 10:14:35 Modified: varia/src/main/org/jboss/jmx/adaptor/snmp/agent ReadOnlyException.java RequestHandlerImpl.java Added: varia/src/main/org/jboss/jmx/adaptor/snmp/agent ComparableSnmpObjectId.java Log: Handle oid sorting and comparing through a ComparableSnmpObjectId-Class. With use of it, fix JBAS-3178. Revision Changes Path 1.5 +8 -1 contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/ReadOnlyException.java (In the diff below, changes in quantity of whitespace are not shown.) Index: ReadOnlyException.java =================================================================== RCS file: /cvsroot/jboss/contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/ReadOnlyException.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- ReadOnlyException.java 30 May 2006 19:29:26 -0000 1.4 +++ ReadOnlyException.java 10 Jul 2006 14:14:35 -0000 1.5 @@ -21,6 +21,8 @@ */ package org.jboss.jmx.adaptor.snmp.agent; +import org.opennms.protocols.snmp.SnmpObjectId; + /** * This exception is thrown when an entry is read only and * a client wants to write to it. @@ -34,4 +36,9 @@ { super("OID " + oid + " is read only"); } + + public ReadOnlyException(SnmpObjectId oid) + { + super("OID " + oid + " is read only"); + } } 1.3 +198 -198 contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java (In the diff below, changes in quantity of whitespace are not shown.) Index: RequestHandlerImpl.java =================================================================== RCS file: /cvsroot/jboss/contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- RequestHandlerImpl.java 6 May 2006 23:24:38 -0000 1.2 +++ RequestHandlerImpl.java 10 Jul 2006 14:14:35 -0000 1.3 @@ -25,9 +25,10 @@ import java.net.InetAddress; import java.util.Iterator; import java.util.List; -import java.util.Set; import java.util.SortedMap; +import java.util.SortedSet; import java.util.TreeMap; +import java.util.TreeSet; import javax.management.Attribute; import javax.management.MBeanServer; @@ -57,7 +58,7 @@ * * @author <a href="mailto:hw...@pi...>">Heiko W. Rupp</a> * @author <a href="mailto:dim...@jb...">Dimitris Andreadis</a> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ public class RequestHandlerImpl extends RequestHandlerSupport implements Reconfigurable @@ -67,9 +68,12 @@ private static final String NO_ENTRY_FOUND_FOR_OID = "No entry found for oid "; private static final String SKIP_ENTRY = " - skipping entry"; + /** Bindings from oid to mbean */ protected SortedMap bindings = new TreeMap(); + private SortedSet oidKeys = null; + /** Has this RequestHandler instance been initialized? */ private boolean initialized = false; @@ -80,7 +84,8 @@ */ public RequestHandlerImpl() { - // empty + bindings = new TreeMap(); + oidKeys = new TreeSet(); } // RequestHandler Implementation --------------------------------- @@ -96,8 +101,8 @@ public void initialize(String resourceName, MBeanServer server, Logger log, Clock uptime) throws Exception { + log.debug("initialize() with res=" + resourceName); super.initialize(resourceName, server, log, uptime); - log.debug("initialized() with res=" + resourceName); if (resourceName != null) initializeBindings(); else @@ -147,6 +152,8 @@ */ public SnmpPduRequest snmpReceivedGet(SnmpPduPacket pdu, boolean getNext) { + try + { SnmpPduRequest response = null; int pduLength = pdu.getLength(); final boolean trace = log.isTraceEnabled(); @@ -169,30 +176,33 @@ { /* * We call getNextOid() to find out what is the next valid OID - * instance in the supported MIB (sub-)tree. Assign that OID to - * the VB List and then proceed same as that of get request. If - * the passed oid is already the last, we flag it. - */ - String oids = oid.toString(); - try + * instance in the supported MIB (sub-)tree. Assign that OID to the + * VB List and then proceed same as that of get request. If the + * passed oid is already the last, we flag it. + */ + ComparableSnmpObjectId coid = new ComparableSnmpObjectId(oid); + oid = getNextOid(coid, true); + if (oid == null) { - oids = getNextOid(oid.toString()); - oid = new SnmpObjectId(oids); - pdu.setVarBindAt(i, new SnmpVarBind(oid)); + good = false; } - catch (NoSuchFieldException nse) - { // abused - good = false; // no next oid found + else + { + pdu.setVarBindAt(i, new SnmpVarBind(oid)); } } + if (oid!=null) vblist[i] = new SnmpVarBind(oid); + else + vblist[i] = new SnmpVarBind(vb.getName()); // oid passed in + if (trace) - log.trace("oid=" + oid.toString()); + log.trace("oid=" + oid); SnmpSyntax result = null; - if (bindings != null) - result = getValueFor(oid.toString()); + if (good && bindings != null) + result = getValueFor(oid); if (trace) log.trace("got result of " + result); @@ -201,7 +211,7 @@ { errorStatus = SnmpPduPacket.ErrNoSuchName; errorIndex = i + 1; - // log.debug("Error Occured " + vb.getName().toString()); + log.debug("Error Occured " + vb.getName().toString()); } else { @@ -210,11 +220,17 @@ + vblist[i].getName().toString()); log.debug(" --> " + vblist[i].getValue().toString()); } - } + } // for ... response = new SnmpPduRequest(SnmpPduPacket.RESPONSE, vblist); response.setErrorStatus(errorStatus); response.setErrorIndex(errorIndex); return response; + } catch (Exception e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } } /** @@ -250,7 +266,7 @@ SnmpSyntax result = null; try { - result = setValueFor(oid.toString(),newVal); + result = setValueFor(oid,newVal); } catch (ReadOnlyException e) { @@ -389,8 +405,10 @@ return; } log.debug("Found " + mappings.size() + " attribute mappings"); + /** + * We have the MBeans now. Put them into the bindungs. + */ - // Turn the parsed mappings into bindings. Iterator it = mappings.iterator(); while (it.hasNext()) { @@ -410,11 +428,11 @@ BindEntry be = new BindEntry(oid, mmb.getName(), ma.getName()); be.isReadWrite = ma.isReadWrite(); + ComparableSnmpObjectId coid = new ComparableSnmpObjectId(oid); + if (log.isTraceEnabled()) log.trace("New bind entry " + be); - - if (bindings.containsKey(oid)) - { + if (bindings.containsKey(coid)) { log.info("Duplicate oid " + oid + SKIP_ENTRY); continue; } @@ -428,7 +446,9 @@ log.info("Invalid attribute name " + ma.getName() + " for oid " + oid + SKIP_ENTRY); continue; } - bindings.put(oid, be); + bindings.put(coid, be); + oidKeys.add(coid); + } } } @@ -440,8 +460,8 @@ * The oid we want a value for * @return SnmpNull if no value present */ - private SnmpSyntax getValueFor(final String oid) - { + private SnmpSyntax getValueFor(final SnmpObjectId oid) { + BindEntry be = findBindEntryForOid(oid); SnmpSyntax ssy = null; if (be != null) @@ -496,7 +516,7 @@ * @return null on success, non-null on failure * @throws ReadOnlyException If the referred entry is read only. */ - private SnmpSyntax setValueFor(final String oid, final SnmpSyntax newVal) throws ReadOnlyException + private SnmpSyntax setValueFor(final SnmpObjectId oid, final SnmpSyntax newVal) throws ReadOnlyException { final boolean trace = log.isTraceEnabled(); @@ -563,111 +583,88 @@ return ssy; } + /** * Lookup a BinEntry on the given oid. If the oid ends in .0, * then the .0 will be stripped of before the search. * @param oid The oid look up. * @return a bind entry or null. */ - private BindEntry findBindEntryForOid(final String oid) + private BindEntry findBindEntryForOid(final SnmpObjectId oid) { + + ComparableSnmpObjectId coid= new ComparableSnmpObjectId(oid); + + if (coid.isLeaf()) { - String localOid = oid; - if (oid.endsWith(".0")) - localOid = oid.substring(0,oid.length()-2); + coid = coid.removeLastPart(); + } + BindEntry be = (BindEntry)bindings.get(coid); - BindEntry be = (BindEntry) bindings.get(localOid); return be; } /** - * Tries to retrieve the next oid following the current one - * - * @param in - * an oid - * @return an oid - * @throws NoSuchFieldException - * if no next oid can be found - */ - private String getNextOid(final String in) throws NoSuchFieldException - { - final boolean trace = log.isTraceEnabled(); + * Return the next oid that is larger than ours. + * @param oid the starting oid + * @param stayInSubtree if true, the next oid will not have a different prefix than the one of oid. + * @return the next oid or null if none found. + */ + private ComparableSnmpObjectId getNextOid(final ComparableSnmpObjectId oid, boolean stayInSubtree) { + ComparableSnmpObjectId coid = new ComparableSnmpObjectId(oid); + + + if (coid.isLeaf()) + coid = coid.removeLastPart(); + + SortedSet ret; + ret= oidKeys.tailSet(oid); // get oids >= oid + Iterator it = ret.iterator(); + ComparableSnmpObjectId roid=null; - String roid = in.substring(0, in.lastIndexOf('.')); - - if (trace) - log.trace("in: " + in + " roi: " + roid); - - Set oids = bindings.keySet(); - Iterator it = oids.iterator(); - while (it.hasNext()) + /* + * If there are elements in the tail set, then + * - get first one. + * - if first is input (which it is supposed to be according to the contract of + * SortedSet.tailSet() , then get next, which is the + * one we look for. + */ + if (it.hasNext()) { - String id = (String) it.next(); - int comp = compareOid(in, id); - if (trace) - log.trace("--- found id " + id + " comp = " + comp); - - if (comp >= 0) - continue; - - if (trace) - log.trace("Returning " + id); - - return id; + roid = (ComparableSnmpObjectId)it.next(); // oid } - if (trace) - log.trace("## no next oid found for " + in); - throw new NoSuchFieldException(); + if (roid == null) + { + return null; // roid is null, } - /** - * Compare the two passed oid-strings. - * - * @param oid1 - * @param oid2 - * @return 0 when equal, 1 if oid2 > oid1 and -1 if oid1>oid2 - */ - private int compareOid(final String oid1, final String oid2) + if (roid.compareTo(coid)==0) // input elment { - int res; - int nd1 = countDots(oid1); - int nd2 = countDots(oid2); - res = nd1 - nd2; - if (res != 0) // different number of dots -> not equal - return res; - - // equal number of dots. Check for same prefix (subtree) - String tpref = oid1.substring(0, oid1.lastIndexOf(".")); - String opref = oid2.substring(0, oid2.lastIndexOf(".")); - - res = tpref.compareTo(opref); - - // same prefix - if (res == 0) + // if there is a next element, then it is ours. + if (it.hasNext()) { - String tsuf = oid1.substring(oid1.lastIndexOf(".") + 1); - String osuf = oid2.substring(oid2.lastIndexOf(".") + 1); - int tval = Integer.parseInt(tsuf); - int oval = Integer.parseInt(osuf); - - res = tval - oval; + roid = (ComparableSnmpObjectId)it.next(); + } + else + { + roid = null; // end of list } - return res; } - /** - * Count the number of dots in the passed String (an oid actually) + /* + * Check if still in subtree if requested to stay within */ - private int countDots(final String in) + if (stayInSubtree && roid != null) { - int count = 0; - for (int i = 0; i < in.length(); i++) - if (in.charAt(i) == '.') - count++; + ComparableSnmpObjectId parent = coid.removeLastPart(); + if (!parent.isRootOf(roid)) + roid = null; + } - return count; + return roid; } + // Inner Class --------------------------------------------------- /** @@ -675,10 +672,9 @@ * * @author <a href="mailto:pi...@us...>">Heiko W. Rupp</a> */ - private class BindEntry implements Comparable - { - private final String oid; - private final int numDots; + private class BindEntry implements Comparable { + private final ComparableSnmpObjectId oid; + private ObjectName mbean; private Attribute attr; private String mName; @@ -695,10 +691,20 @@ * @param attrName * The name of the attribute to query */ - BindEntry(final String oid, final String mbName, final String attrName) - { - this.oid = oid; - numDots = countDots(oid); + BindEntry(final String oidString, final String mbName, final String attrName) { + this(new ComparableSnmpObjectId(oidString), + mbName, + attrName); + } + + /** + * Constructs a new BindEntry. + * @param coid The SNMP-oid, this entry will use. + * @param mbName The name of an MBean with attribute to query + * @param attrName The name of the attribute to query + */ + BindEntry(final ComparableSnmpObjectId coid, final String mbName, final String attrName) { + oid = coid; this.mName = mbName; this.aName = attrName; try @@ -715,8 +721,21 @@ } } - public Attribute getAttr() - { + /** + * A string representation of this BindEntry + */ + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append("[oid="); + buf.append(oid).append(", mbean="); + buf.append(mName).append(", attr="); + buf.append(aName).append(", rw="); + buf.append(isReadWrite).append("]"); + + return buf.toString(); + } + + public Attribute getAttr() { return attr; } @@ -725,17 +744,12 @@ return mbean; } - public String getOid() + public ComparableSnmpObjectId getOid() { return oid; } - public int getNumDots() - { - return numDots; - } - /** * Compare two BindEntries. Ordering is defined at oid-level. * @@ -759,24 +773,10 @@ if (getOid().equals(obe.getOid())) return 0; - int res = compareOid(oid, obe.getOid()); + int res =oid.compare(obe.getOid()); return res; } - /** - * A string representation of this BindEntry - */ - public String toString() - { - StringBuffer buf = new StringBuffer(); - buf.append("[oid="); - buf.append(oid).append(", mbean="); - buf.append(mName).append(", attr="); - buf.append(aName).append(", rw="); - buf.append(isReadWrite).append("]"); - - return buf.toString(); - } } } 1.1 date: 2006/07/10 14:14:35; author: pilhuhn; state: Exp;contrib/varia/src/main/org/jboss/jmx/adaptor/snmp/agent/ComparableSnmpObjectId.java Index: ComparableSnmpObjectId.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.jmx.adaptor.snmp.agent; import org.opennms.protocols.snmp.SnmpObjectId; /** * Provide SnmpObjectIds that are Comparable to be used * in SortedSets etc. * @author <a href="mailto:hw...@pi...">Heiko W. Rupp</a> * @version $Revision: 1.1 $ */ public class ComparableSnmpObjectId extends SnmpObjectId implements Comparable { public ComparableSnmpObjectId(String oid) { super(oid); } public ComparableSnmpObjectId(SnmpObjectId oid) { super(oid); } public ComparableSnmpObjectId(int[] identifiers) { super(identifiers); } /** * Compare to the passed object. Uses compare() * from the underlying snmp-library * @see SnmpObjectId.compare() * @param o Object to compare with (Usually a ComparableSnmpObjectId) * @return -1, if no SnmpObjectId passed in, the result of the underlying compare otherwise. */ public int compareTo(Object o) { if (o==null) return -1; if (!(o instanceof SnmpObjectId)) return -1; return this.compare((SnmpObjectId)o); } /** * This object is a leaf if the last part of the oid parts is a 0 (Zero) * @return true if the oid ends in 0 */ public boolean isLeaf() { int[] ids = getIdentifiers(); if (ids.length==0) { // no data present (should not happen) return false; } if (ids[ids.length-1]==0) { return true; } return false; } /** * Removes the last oid-component. * Example .1.2.3.4.0 as input yields .1.2.3.4 as output * @return an oid with the last part removed. */ public ComparableSnmpObjectId removeLastPart() { int[] ids = getIdentifiers(); int[] outs = new int[ids.length-1]; int len = ids.length-1; for (int i = 0; i<len ; i++) { outs[i]=ids[i]; } ComparableSnmpObjectId out = new ComparableSnmpObjectId(outs); return out; } /** * Build an oid where the second last component * (after removing a .0 of a leaf) is increased by 1. * The last component is removed, to the result actually forms * the root of a subtree, that is adjacent to the subtree this * object is in. * Example .1.2.3.4.0 -> .1.2.4 * Example .1.2.3.4.5 -> .1.2.4 * @return */ public ComparableSnmpObjectId getNextArc() { ComparableSnmpObjectId cid = this; if (isLeaf()) { cid = removeLastPart(); } cid = cid.removeLastPart(); int[] ids = cid.getIdentifiers(); int[] ods = new int[ids.length]; System.arraycopy(ids, 0, ods, 0, ids.length); int len = ods.length-1; ods[len]++; ComparableSnmpObjectId ret = new ComparableSnmpObjectId(ods); return ret; } } |
From: Carlo de W. <ca...@ne...> - 2006-07-10 13:57:03
|
User: wolfc Date: 06/07/10 09:56:59 Added: src/test/org/jboss/ejb3/test/timer TimerTesterService.java Log: EJBTHREE-613: unit test Revision Changes Path 1.1 date: 2006/07/10 13:56:59; author: wolfc; state: Exp;jboss-ejb3/src/test/org/jboss/ejb3/test/timer/TimerTesterService.java Index: TimerTesterService.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.ejb3.test.timer; import javax.ejb.Local; import javax.ejb.Timeout; import javax.ejb.Timer; import org.jboss.annotation.ejb.Service; import org.jboss.logging.Logger; /** * Comment * * @author <a href="mailto:car...@jb...">Carlo de Wolf</a> * @version $Revision: 1.1 $ */ @Local(TimerTester.class) @Service public class TimerTesterService extends BaseTimerTesterBean { private static final Logger log = Logger.getLogger(TimerTesterService.class); @Timeout public void timeoutHandler(Timer timer) { log.info("EJB TIMEOUT!!!!"); timerCalled = true; //timer.cancel(); } } |
From: Carlo de W. <ca...@ne...> - 2006-07-10 13:57:02
|
User: wolfc Date: 06/07/10 09:56:59 Modified: src/test/org/jboss/ejb3/test/timer/unit RemoteUnitTestCase.java Log: EJBTHREE-613: unit test Revision Changes Path 1.10 +14 -1 jboss-ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java (In the diff below, changes in quantity of whitespace are not shown.) Index: RemoteUnitTestCase.java =================================================================== RCS file: /cvsroot/jboss/jboss-ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -b -r1.9 -r1.10 --- RemoteUnitTestCase.java 12 Jun 2006 13:30:44 -0000 1.9 +++ RemoteUnitTestCase.java 10 Jul 2006 13:56:59 -0000 1.10 @@ -29,7 +29,7 @@ * Sample client for the jboss container. * * @author <a href="mailto:bi...@bu...">Bill Burke</a> - * @version $Id: RemoteUnitTestCase.java,v 1.9 2006/06/12 13:30:44 wolfc Exp $ + * @version $Id: RemoteUnitTestCase.java,v 1.10 2006/07/10 13:56:59 wolfc Exp $ */ public class RemoteUnitTestCase @@ -47,6 +47,19 @@ } + public void testService() throws Exception + { + TimerTester test = (TimerTester) getInitialContext().lookup("TimerTesterService/local"); + test.startTimer(5000); + test.accessTimer(); + Thread.sleep(6000); + assertTrue(test.isTimerCalled()); + test.startTimerViaEJBContext(5000); + test.accessTimer(); + Thread.sleep(6000); + assertTrue(test.isTimerCalled()); + } + public void testSimple() throws Exception { TimerTester test = (TimerTester) this.getInitialContext().lookup("TimerTesterBean/remote"); |
From: Manik S. <msu...@jb...> - 2006-07-10 13:39:38
|
User: msurtani Date: 06/07/10 09:39:36 Modified: etc/META-INF Tag: Branch_JBossCache_1_4_0 buddyreplication-service.xml Log: updated defaults Revision Changes Path No revision No revision 1.4.2.1 +4 -3 JBossCache/etc/META-INF/buddyreplication-service.xml (In the diff below, changes in quantity of whitespace are not shown.) Index: buddyreplication-service.xml =================================================================== RCS file: /cvsroot/jboss/JBossCache/etc/META-INF/buddyreplication-service.xml,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -b -r1.4 -r1.4.2.1 --- buddyreplication-service.xml 1 Jun 2006 19:04:52 -0000 1.4 +++ buddyreplication-service.xml 10 Jul 2006 13:39:35 -0000 1.4.2.1 @@ -131,13 +131,14 @@ from groups --> <buddyCommunicationTimeout>2000</buddyCommunicationTimeout> - <!-- the following three elements, all relating to data gravitation, default to true --> + <!-- the following three elements, all relating to data gravitation, default to false --> <!-- Should data gravitation be attempted whenever there is a cache miss on finding a node? If false, data will only be gravitated if an Option is set enabling it --> - <autoDataGravitation>true</autoDataGravitation> + <autoDataGravitation>false</autoDataGravitation> <!-- removes data on remote caches' trees and backup subtrees when gravitated to a new data owner --> <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind> - <!-- search backup subtrees as well for data when gravitating --> + <!-- search backup subtrees as well for data when gravitating. Results in backup nodes being able to + answer data gravitation requests. --> <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees> </config> |
From: Manik S. <msu...@jb...> - 2006-07-10 13:14:21
|
User: msurtani Date: 06/07/10 09:14:16 Modified: docs/tutorial/en Tag: Branch_JBossCache_1_4_0 master.xml Log: formatting Revision Changes Path No revision No revision 1.13.2.3 +12 -12 JBossCache/docs/tutorial/en/master.xml (In the diff below, changes in quantity of whitespace are not shown.) Index: master.xml =================================================================== RCS file: /cvsroot/jboss/JBossCache/docs/tutorial/en/master.xml,v retrieving revision 1.13.2.2 retrieving revision 1.13.2.3 diff -u -b -r1.13.2.2 -r1.13.2.3 --- master.xml 7 Jul 2006 17:45:19 -0000 1.13.2.2 +++ master.xml 10 Jul 2006 13:14:16 -0000 1.13.2.3 @@ -26,8 +26,8 @@ In this tutorial, we will demonstrate the usage of both cache features. For details of the usage and APIs, please refer to the user manuals for <ulink - url="http://www.jboss.org/products/jbosscache/docs">TreeCache</ulink> and <ulink - url="http://www.jboss.org/products/jbosscache/docs">PojoCache</ulink>.</para> + url="http://labs.jboss.org/portal/jbosscache/docs/index.html">TreeCache</ulink> and <ulink + url="http://labs.jboss.org/portal/jbosscache/docs/index.html">PojoCache</ulink>.</para> </section> <section> @@ -56,7 +56,7 @@ <title>Configuration</title> <para>First download the standalone TreeCache code from <ulink - url="http://www.jboss.com/products/jbosscache/downloads">here</ulink>. + url="http://labs.jboss.org/portal/jbosscache/download/index.html">here</ulink>. Unzip it, and you will get a root directory (jboss-cache in our example).</para> @@ -66,13 +66,13 @@ <itemizedlist> <listitem> - <para>log4j.xml. Logging output. You can turn on logging level or + <para><literal>log4j.xml</literal>. Logging output. You can turn on logging level or change log file directory (default is - <literal>/tmp/test.log</literal>).</para> + <literal>/tmp/jbosscache.log</literal>).</para> </listitem> <listitem> - <para>replSync-service.xml. Tree cache configuration file (file name + <para><literal>replSync-service.xml</literal>. Tree cache configuration file (file name is not fixed. You specify the file to be read in in <literal>PropertyConfigurator</literal>). The settings are for a replicated, synchronous, and transactional cache. The default @@ -85,7 +85,7 @@ </listitem> <listitem> - <para>jboss-aop.xml. AOP pointcut and advice definition for the + <para><literal>jboss-aop.xml</literal>. AOP pointcut and advice definition for the example POJO classes, Person and Address, respectively. For details of how to put your own class under AOP, please refer to the <ulink url="http://www.jboss.org/products/jbosscache/docs">PojoCache</ulink>. This file is read in @@ -102,7 +102,7 @@ <itemizedlist> <listitem> - <para>build.sh (or build.bat for DOS). Simple build script that wraps + <para><literal>build.sh</literal> (or <literal>build.bat</literal> for DOS/Windows). Simple build script that wraps around ant. Users can simply type <literal>sh build.sh</literal> for help. Note from now on, we will only refer to the Unix version with the understanding that there is a corresponding DOS counterpart. The @@ -110,24 +110,24 @@ </listitem> <listitem> - <para>runDemoShell.sh. Simple run script that wraps around BeanShell. + <para><literal>runDemoShell.sh</literal>. Simple run script that wraps around BeanShell. This is used to operate the replicated cache through interactive command line.</para> </listitem> <listitem> - <para>plain.bsh. Java codes that instantiate and configure the cache. + <para><literal>plain.bsh</literal>. Java code that instantiate and configure the cache. It also creates an example cache entry.</para> </listitem> <listitem> - <para>aop.bsh. Java codes that instantiate and configure the aop + <para><literal>aop.bsh</literal>. Java codes that instantiate and configure the aop cache. In addition, it also sets up the example POJO (plaing old Java object) classes (e.g., Person and Address).</para> </listitem> <listitem> - <para>aopWithTx.bsh. Same with aop.bsh except it also instantiates a + <para><literal>aopWithTx.bsh</literal>. Same with aop.bsh except it also instantiates a transaction context.</para> </listitem> </itemizedlist> |
From: Adrian B. <adr...@jb...> - 2006-07-10 13:12:35
|
User: adrian Date: 06/07/10 09:12:33 Modified: src/main/org/jboss/mq/pm/jdbc2 PersistenceManager.java Log: [JBAS-3370] - Port from JBoss4 Revision Changes Path 1.42 +2 -2 jbossmq/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java (In the diff below, changes in quantity of whitespace are not shown.) Index: PersistenceManager.java =================================================================== RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -b -r1.41 -r1.42 --- PersistenceManager.java 27 May 2006 15:00:47 -0000 1.41 +++ PersistenceManager.java 10 Jul 2006 13:12:33 -0000 1.42 @@ -73,7 +73,7 @@ * @author Jayesh Parayali (jay...@ya...) * @author Hiram Chirino (coj...@ho...) * @author Adrian Brock (ad...@jb...) - * @version $Revision: 1.41 $ + * @version $Revision: 1.42 $ */ public class PersistenceManager extends ServiceMBeanSupport implements PersistenceManagerMBean, org.jboss.mq.pm.PersistenceManager, CacheStore @@ -908,7 +908,7 @@ if (xid != null) setBlob(stmt, 2, xid); else - stmt.setNull(2, java.sql.Types.BIGINT); + stmt.setNull(2, java.sql.Types.BLOB); } stmt.executeUpdate(); } |
From: Adrian B. <adr...@jb...> - 2006-07-10 13:07:25
|
User: adrian Date: 06/07/10 09:07:22 Modified: src/main/org/jboss/mq/pm/jdbc2 Tag: Branch_4_0 PersistenceManager.java Log: [JBAS-3370] - Pass the correct type when inserting null XIDs Revision Changes Path No revision No revision 1.29.2.11 +2 -2 jbossmq/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java (In the diff below, changes in quantity of whitespace are not shown.) Index: PersistenceManager.java =================================================================== RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/pm/jdbc2/PersistenceManager.java,v retrieving revision 1.29.2.10 retrieving revision 1.29.2.11 diff -u -b -r1.29.2.10 -r1.29.2.11 --- PersistenceManager.java 27 May 2006 14:03:25 -0000 1.29.2.10 +++ PersistenceManager.java 10 Jul 2006 13:07:22 -0000 1.29.2.11 @@ -73,7 +73,7 @@ * @author Jayesh Parayali (jay...@ya...) * @author Hiram Chirino (coj...@ho...) * @author Adrian Brock (ad...@jb...) - * @version $Revision: 1.29.2.10 $ + * @version $Revision: 1.29.2.11 $ */ public class PersistenceManager extends ServiceMBeanSupport implements PersistenceManagerMBean, org.jboss.mq.pm.PersistenceManager, CacheStore @@ -908,7 +908,7 @@ if (xid != null) setBlob(stmt, 2, xid); else - stmt.setNull(2, java.sql.Types.BIGINT); + stmt.setNull(2, java.sql.Types.BLOB); } stmt.executeUpdate(); } |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:42
|
User: adrian Date: 06/07/10 08:18:48 Modified: src/tests/org/jboss/test/metadata/retrieval/support TestMetaDataRetrieval.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.2 +23 -0 container/src/tests/org/jboss/test/metadata/retrieval/support/TestMetaDataRetrieval.java (In the diff below, changes in quantity of whitespace are not shown.) Index: TestMetaDataRetrieval.java =================================================================== RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/metadata/retrieval/support/TestMetaDataRetrieval.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- TestMetaDataRetrieval.java 22 Jun 2006 14:57:30 -0000 1.1 +++ TestMetaDataRetrieval.java 10 Jul 2006 12:18:48 -0000 1.2 @@ -29,17 +29,28 @@ import org.jboss.metadata.spi.retrieval.MetaDataRetrieval; import org.jboss.metadata.spi.retrieval.MetaDatasItem; import org.jboss.metadata.spi.retrieval.ValidTime; +import org.jboss.metadata.spi.scope.Scope; +import org.jboss.metadata.spi.scope.ScopeKey; +import org.jboss.metadata.spi.scope.ScopeLevel; /** * TestMetaDataRetrieval. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class TestMetaDataRetrieval implements MetaDataRetrieval { + private static final ScopeLevel testLevel = new ScopeLevel(1, "TEST"); + private static final ScopeKey testScopeKey = new ScopeKey(new Scope(testLevel, "TEST")); + public String lastMethod; + public ScopeKey getScope() + { + return testScopeKey; + } + public ValidTime getValidTime() { lastMethod = "getValidTime"; @@ -58,12 +69,24 @@ return null; } + public AnnotationsItem retrieveLocalAnnotations() + { + lastMethod = "retrieveLocalAnnotations"; + return null; + } + public MetaDatasItem retrieveMetaData() { lastMethod = "retrieveMetaData"; return null; } + public MetaDatasItem retrieveLocalMetaData() + { + lastMethod = "retrieveLocalMetaData"; + return null; + } + public <T> MetaDataItem<T> retrieveMetaData(Class<T> type) { lastMethod = "retrieveMetaData(Class)"; |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:35
|
User: adrian Date: 06/07/10 08:18:48 Modified: src/main/org/jboss/metadata/plugins/context AbstractMetaDataContext.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.2 +48 -2 container/src/main/org/jboss/metadata/plugins/context/AbstractMetaDataContext.java (In the diff below, changes in quantity of whitespace are not shown.) Index: AbstractMetaDataContext.java =================================================================== RCS file: /cvsroot/jboss/container/src/main/org/jboss/metadata/plugins/context/AbstractMetaDataContext.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- AbstractMetaDataContext.java 22 Jun 2006 14:57:30 -0000 1.1 +++ AbstractMetaDataContext.java 10 Jul 2006 12:18:48 -0000 1.2 @@ -23,6 +23,7 @@ import java.lang.annotation.Annotation; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -36,12 +37,14 @@ import org.jboss.metadata.spi.retrieval.ValidTime; import org.jboss.metadata.spi.retrieval.cummulative.CummulativeAnnotationsItem; import org.jboss.metadata.spi.retrieval.cummulative.CummulativeMetaDatasItem; +import org.jboss.metadata.spi.scope.Scope; +import org.jboss.metadata.spi.scope.ScopeKey; /** * AbstractMetaDataContext. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class AbstractMetaDataContext implements MetaDataContext { @@ -51,6 +54,9 @@ /** The parent context */ private MetaDataContext parent; + /** The scope */ + private volatile ScopeKey scopeKey; + /** * Create a new AbstractMetaDataContext. * @@ -94,6 +100,23 @@ this.retrievals = retrievals; } + public ScopeKey getScope() + { + if (scopeKey == null) + { + ScopeKey key = new ScopeKey(); + for (MetaDataRetrieval retrieval : getRetrievals()) + { + ScopeKey retrievalKey = retrieval.getScope(); + Collection<Scope> scopes = retrievalKey.getScopes(); + for (Scope scope : scopes) + key.addScope(scope); + } + scopeKey = key; + } + return scopeKey; + } + public ValidTime getValidTime() { ValidTime result = null; @@ -120,6 +143,11 @@ return result; } + public MetaDataContext getParent() + { + return parent; + } + public List<MetaDataRetrieval> getRetrievals() { if (parent == null) @@ -130,6 +158,11 @@ return result; } + public List<MetaDataRetrieval> getLocalRetrievals() + { + return retrievals; + } + public void append(MetaDataRetrieval retrieval) { if (retrieval == null) @@ -139,6 +172,7 @@ retrievals = new CopyOnWriteArrayList<MetaDataRetrieval>(retrievals); retrievals.add(retrieval); + scopeKey = null; } public void prepend(MetaDataRetrieval retrieval) @@ -150,6 +184,7 @@ retrievals = new CopyOnWriteArrayList<MetaDataRetrieval>(retrievals); retrievals.add(0, retrieval); + scopeKey = null; } public void remove(MetaDataRetrieval retrieval) @@ -161,11 +196,17 @@ throw new IllegalStateException("Must have at least one retrieval"); retrievals.remove(retrieval); + scopeKey = null; } public AnnotationsItem retrieveAnnotations() { - return new CummulativeAnnotationsItem(this); + return new CummulativeAnnotationsItem(this, true); + } + + public AnnotationsItem retrieveLocalAnnotations() + { + return new CummulativeAnnotationsItem(this, false); } public <T extends Annotation> AnnotationItem<T> retrieveAnnotation(Class<T> annotationType) @@ -186,7 +227,12 @@ public MetaDatasItem retrieveMetaData() { - return new CummulativeMetaDatasItem(this); + return new CummulativeMetaDatasItem(this, true); + } + + public MetaDatasItem retrieveLocalMetaData() + { + return new CummulativeMetaDatasItem(this, false); } public <T> MetaDataItem<T> retrieveMetaData(Class<T> type) |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:33
|
User: adrian Date: 06/07/10 08:18:51 Added: src/main/org/jboss/metadata/spi/repository MetaDataRepository.java MutableMetaDataRepository.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.1 date: 2006/07/10 12:18:51; author: adrian; state: Exp;container/src/main/org/jboss/metadata/spi/repository/MetaDataRepository.java Index: MetaDataRepository.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metadata.spi.repository; import java.util.Set; import org.jboss.metadata.spi.MetaData; import org.jboss.metadata.spi.repository.visitor.MetaDataRepositoryVisitor; import org.jboss.metadata.spi.retrieval.MetaDataRetrieval; import org.jboss.metadata.spi.scope.ScopeKey; /** * MetaDataRepository. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public interface MetaDataRepository { /** * Get the meta data for a scope key * * @param key the key * @return the meta data */ MetaData getMetaData(ScopeKey key); /** * Get the meta data retrieval for a scope key * * @param key the key * @return the meta data */ MetaDataRetrieval getMetaDataRetrieval(ScopeKey key); /** * Get the children of this scope * * @param key the key * @return the children */ Set<ScopeKey> getChildren(ScopeKey key); /** * Visit each node * * @param visitor the visitor * @return the matching scopes */ Set<ScopeKey> matchScopes(MetaDataRepositoryVisitor visitor); } 1.1 date: 2006/07/10 12:18:51; author: adrian; state: Exp;container/src/main/org/jboss/metadata/spi/repository/MutableMetaDataRepository.java Index: MutableMetaDataRepository.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metadata.spi.repository; import org.jboss.metadata.spi.retrieval.MetaDataRetrieval; import org.jboss.metadata.spi.scope.ScopeKey; /** * MutableMetaDataRepository. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public interface MutableMetaDataRepository extends MetaDataRepository { /** * Add a meta data retrieval for the given scope * * @param retrieval the retrieval * @return any previous retrieval */ MetaDataRetrieval addMetaDataRetrieval(MetaDataRetrieval retrieval); /** * Remove a meta data retrieval for the given scope * * @param key the key * @param retrieval the retrieval * @return any previous retrieval */ MetaDataRetrieval removeMetaDataRetrieval(ScopeKey key); } |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:33
|
User: adrian Date: 06/07/10 08:18:51 Added: src/main/org/jboss/metadata/plugins/repository/visitor FuzzyMetaDataRepositoryVisitor.java ChildrenMetaDataRepositoryVisitor.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.1 date: 2006/07/10 12:18:51; author: adrian; state: Exp;container/src/main/org/jboss/metadata/plugins/repository/visitor/FuzzyMetaDataRepositoryVisitor.java Index: FuzzyMetaDataRepositoryVisitor.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metadata.plugins.repository.visitor; import java.util.Collection; import java.util.Iterator; import org.jboss.metadata.spi.repository.MetaDataRepository; import org.jboss.metadata.spi.repository.visitor.MetaDataRepositoryVisitor; import org.jboss.metadata.spi.scope.Scope; import org.jboss.metadata.spi.scope.ScopeKey; import org.jboss.metadata.spi.scope.ScopeLevel; /** * FuzzyMetaDataRepositoryVisitor. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class FuzzyMetaDataRepositoryVisitor implements MetaDataRepositoryVisitor { /** The key scopes */ private Scope[] matchScopes; /** * Create a new FuzzyMetaDataRepositoryVisitor. * * @param matchKey the match key */ public FuzzyMetaDataRepositoryVisitor(ScopeKey matchKey) { if (matchKey != null) { Collection<Scope> testScopes = matchKey.getScopes(); matchScopes = testScopes.toArray(new Scope[testScopes.size()]); } } public boolean matchScope(MetaDataRepository repository, ScopeKey key) { if (matchScopes == null || matchScopes.length == 0) return true; boolean match = false; int index = 0; Iterator<Scope> i = key.getScopes().iterator(); Scope repositoryScope = i.next(); Scope matchScope = matchScopes[index]; while (true) { ScopeLevel keyLevel = matchScope.getScopeLevel(); ScopeLevel repositoryLevel = repositoryScope.getScopeLevel(); // Same level if (keyLevel.compareTo(repositoryLevel) == 0) { if (matchScope.equals(repositoryScope)) match = true; else { // No match, we are done match = false; break; } } // Key is next if (keyLevel.compareTo(repositoryLevel) <= 0) { // Ran out of keys if (++index == matchScopes.length) break; matchScope = matchScopes[index]; } else { // Ran out of keys if (i.hasNext() == false) break; repositoryScope = i.next(); } } return match; } } 1.1 date: 2006/07/10 12:18:51; author: adrian; state: Exp;container/src/main/org/jboss/metadata/plugins/repository/visitor/ChildrenMetaDataRepositoryVisitor.java Index: ChildrenMetaDataRepositoryVisitor.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metadata.plugins.repository.visitor; import org.jboss.metadata.spi.repository.MetaDataRepository; import org.jboss.metadata.spi.repository.visitor.MetaDataRepositoryVisitor; import org.jboss.metadata.spi.scope.ScopeKey; /** * FuzzyMetaDataRepositoryVisitor. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class ChildrenMetaDataRepositoryVisitor implements MetaDataRepositoryVisitor { /** The parent */ private ScopeKey parent; /** * Create a new ChildrenMetaDataRepositoryVisitor. * * @param parent the parent */ public ChildrenMetaDataRepositoryVisitor(ScopeKey parent) { if (parent == null) throw new IllegalArgumentException("Null parent"); this.parent = parent; } public boolean matchScope(MetaDataRepository repository, ScopeKey key) { return parent.isParent(key); } } |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:32
|
User: adrian Date: 06/07/10 08:18:47 Modified: src/tests/org/jboss/test/metadata/context/basic/test BasicParentContextBasicMetaDataUnitTestCase.java BasicContextBasicMetaDataUnitTestCase.java BasicParentContextBasicAnnotationsUnitTestCase.java BasicContextBasicAnnotationsUnitTestCase.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.2 +19 -25 container/src/tests/org/jboss/test/metadata/context/basic/test/BasicParentContextBasicMetaDataUnitTestCase.java (In the diff below, changes in quantity of whitespace are not shown.) Index: BasicParentContextBasicMetaDataUnitTestCase.java =================================================================== RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/metadata/context/basic/test/BasicParentContextBasicMetaDataUnitTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- BasicParentContextBasicMetaDataUnitTestCase.java 22 Jun 2006 14:57:28 -0000 1.1 +++ BasicParentContextBasicMetaDataUnitTestCase.java 10 Jul 2006 12:18:47 -0000 1.2 @@ -22,8 +22,9 @@ package org.jboss.test.metadata.context.basic.test; import org.jboss.metadata.plugins.context.AbstractMetaDataContext; -import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader; import org.jboss.metadata.spi.MetaData; +import org.jboss.metadata.spi.loader.MetaDataLoader; +import org.jboss.metadata.spi.loader.MutableMetaDataLoader; import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge; import org.jboss.test.metadata.shared.BasicMetaDataTest; import org.jboss.test.metadata.shared.support.TestMetaData; @@ -37,63 +38,56 @@ * BasicParentContextBasicMetaDataUnitTestCase. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class BasicParentContextBasicMetaDataUnitTestCase extends BasicMetaDataTest { public BasicParentContextBasicMetaDataUnitTestCase(String name) { - super(name); + super(name, false); } - protected MetaData setupEmpty() + protected MetaData setupMetaData(MetaDataLoader loader) { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); AbstractMetaDataContext parent = new AbstractMetaDataContext(null, loader); - MemoryMetaDataLoader empty = new MemoryMetaDataLoader(); + MutableMetaDataLoader empty = createTestMutableMetaDataLoader(); AbstractMetaDataContext context = new AbstractMetaDataContext(parent, empty); return new MetaDataRetrievalToMetaDataBridge(context); } + protected MetaData setupEmpty() + { + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); + return setupMetaData(loader); + } + protected MetaData setupTestMetaData() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addMetaData(new TestMetaDataImpl(), TestMetaData.class); - AbstractMetaDataContext parent = new AbstractMetaDataContext(null, loader); - MemoryMetaDataLoader empty = new MemoryMetaDataLoader(); - AbstractMetaDataContext context = new AbstractMetaDataContext(parent, empty); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } protected MetaData setupTestMetaData12() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addMetaData(new TestMetaData1Impl(), TestMetaData1.class); loader.addMetaData(new TestMetaData2Impl(), TestMetaData2.class); - AbstractMetaDataContext parent = new AbstractMetaDataContext(null, loader); - MemoryMetaDataLoader empty = new MemoryMetaDataLoader(); - AbstractMetaDataContext context = new AbstractMetaDataContext(parent, empty); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } protected MetaData setupTestMetaDataByName() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addMetaData("Test", new TestMetaDataImpl(), TestMetaData.class); - AbstractMetaDataContext parent = new AbstractMetaDataContext(null, loader); - MemoryMetaDataLoader empty = new MemoryMetaDataLoader(); - AbstractMetaDataContext context = new AbstractMetaDataContext(parent, empty); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } protected MetaData setupTestMetaData12ByName() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addMetaData("Test1", new TestMetaData1Impl(), TestMetaData1.class); loader.addMetaData("Test2", new TestMetaData2Impl(), TestMetaData2.class); - AbstractMetaDataContext parent = new AbstractMetaDataContext(null, loader); - MemoryMetaDataLoader empty = new MemoryMetaDataLoader(); - AbstractMetaDataContext context = new AbstractMetaDataContext(parent, empty); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } } 1.2 +18 -16 container/src/tests/org/jboss/test/metadata/context/basic/test/BasicContextBasicMetaDataUnitTestCase.java (In the diff below, changes in quantity of whitespace are not shown.) Index: BasicContextBasicMetaDataUnitTestCase.java =================================================================== RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/metadata/context/basic/test/BasicContextBasicMetaDataUnitTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- BasicContextBasicMetaDataUnitTestCase.java 22 Jun 2006 14:57:28 -0000 1.1 +++ BasicContextBasicMetaDataUnitTestCase.java 10 Jul 2006 12:18:47 -0000 1.2 @@ -22,8 +22,9 @@ package org.jboss.test.metadata.context.basic.test; import org.jboss.metadata.plugins.context.AbstractMetaDataContext; -import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader; import org.jboss.metadata.spi.MetaData; +import org.jboss.metadata.spi.loader.MetaDataLoader; +import org.jboss.metadata.spi.loader.MutableMetaDataLoader; import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge; import org.jboss.test.metadata.shared.BasicMetaDataTest; import org.jboss.test.metadata.shared.support.TestMetaData; @@ -37,53 +38,54 @@ * BasicContextBasicMetaDataUnitTestCase. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class BasicContextBasicMetaDataUnitTestCase extends BasicMetaDataTest { public BasicContextBasicMetaDataUnitTestCase(String name) { - super(name); + super(name, true); } - protected MetaData setupEmpty() + protected MetaData setupMetaData(MetaDataLoader loader) { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); AbstractMetaDataContext context = new AbstractMetaDataContext(null, loader); return new MetaDataRetrievalToMetaDataBridge(context); } + protected MetaData setupEmpty() + { + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); + return setupMetaData(loader); + } + protected MetaData setupTestMetaData() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addMetaData(new TestMetaDataImpl(), TestMetaData.class); - AbstractMetaDataContext context = new AbstractMetaDataContext(null, loader); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } protected MetaData setupTestMetaData12() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addMetaData(new TestMetaData1Impl(), TestMetaData1.class); loader.addMetaData(new TestMetaData2Impl(), TestMetaData2.class); - AbstractMetaDataContext context = new AbstractMetaDataContext(null, loader); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } protected MetaData setupTestMetaDataByName() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addMetaData("Test", new TestMetaDataImpl(), TestMetaData.class); - AbstractMetaDataContext context = new AbstractMetaDataContext(null, loader); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } protected MetaData setupTestMetaData12ByName() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addMetaData("Test1", new TestMetaData1Impl(), TestMetaData1.class); loader.addMetaData("Test2", new TestMetaData2Impl(), TestMetaData2.class); - AbstractMetaDataContext context = new AbstractMetaDataContext(null, loader); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } } 1.2 +15 -15 container/src/tests/org/jboss/test/metadata/context/basic/test/BasicParentContextBasicAnnotationsUnitTestCase.java (In the diff below, changes in quantity of whitespace are not shown.) Index: BasicParentContextBasicAnnotationsUnitTestCase.java =================================================================== RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/metadata/context/basic/test/BasicParentContextBasicAnnotationsUnitTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- BasicParentContextBasicAnnotationsUnitTestCase.java 22 Jun 2006 14:57:28 -0000 1.1 +++ BasicParentContextBasicAnnotationsUnitTestCase.java 10 Jul 2006 12:18:47 -0000 1.2 @@ -22,8 +22,9 @@ package org.jboss.test.metadata.context.basic.test; import org.jboss.metadata.plugins.context.AbstractMetaDataContext; -import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader; import org.jboss.metadata.spi.MetaData; +import org.jboss.metadata.spi.loader.MetaDataLoader; +import org.jboss.metadata.spi.loader.MutableMetaDataLoader; import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge; import org.jboss.test.metadata.shared.BasicAnnotationsTest; import org.jboss.test.metadata.shared.support.TestAnnotation1Impl; @@ -34,42 +35,41 @@ * BasicContextBasicAnnotationsUnitTestCase. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class BasicParentContextBasicAnnotationsUnitTestCase extends BasicAnnotationsTest { public BasicParentContextBasicAnnotationsUnitTestCase(String name) { - super(name); + super(name, false); } - protected MetaData setupEmpty() + protected MetaData setupMetaData(MetaDataLoader loader) { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); AbstractMetaDataContext parent = new AbstractMetaDataContext(null, loader); - MemoryMetaDataLoader empty = new MemoryMetaDataLoader(); + MutableMetaDataLoader empty = createTestMutableMetaDataLoader(); AbstractMetaDataContext context = new AbstractMetaDataContext(parent, empty); return new MetaDataRetrievalToMetaDataBridge(context); } + protected MetaData setupEmpty() + { + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); + return setupMetaData(loader); + } + protected MetaData setupTestAnnotation() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addAnnotation(new TestAnnotationImpl()); - AbstractMetaDataContext parent = new AbstractMetaDataContext(null, loader); - MemoryMetaDataLoader empty = new MemoryMetaDataLoader(); - AbstractMetaDataContext context = new AbstractMetaDataContext(parent, empty); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } protected MetaData setupTestAnnotation12() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addAnnotation(new TestAnnotation1Impl()); loader.addAnnotation(new TestAnnotation2Impl()); - AbstractMetaDataContext parent = new AbstractMetaDataContext(null, loader); - MemoryMetaDataLoader empty = new MemoryMetaDataLoader(); - AbstractMetaDataContext context = new AbstractMetaDataContext(parent, empty); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } } 1.2 +14 -10 container/src/tests/org/jboss/test/metadata/context/basic/test/BasicContextBasicAnnotationsUnitTestCase.java (In the diff below, changes in quantity of whitespace are not shown.) Index: BasicContextBasicAnnotationsUnitTestCase.java =================================================================== RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/metadata/context/basic/test/BasicContextBasicAnnotationsUnitTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- BasicContextBasicAnnotationsUnitTestCase.java 22 Jun 2006 14:57:28 -0000 1.1 +++ BasicContextBasicAnnotationsUnitTestCase.java 10 Jul 2006 12:18:47 -0000 1.2 @@ -22,8 +22,9 @@ package org.jboss.test.metadata.context.basic.test; import org.jboss.metadata.plugins.context.AbstractMetaDataContext; -import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader; import org.jboss.metadata.spi.MetaData; +import org.jboss.metadata.spi.loader.MetaDataLoader; +import org.jboss.metadata.spi.loader.MutableMetaDataLoader; import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge; import org.jboss.test.metadata.shared.BasicAnnotationsTest; import org.jboss.test.metadata.shared.support.TestAnnotation1Impl; @@ -34,36 +35,39 @@ * BasicContextBasicAnnotationsUnitTestCase. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class BasicContextBasicAnnotationsUnitTestCase extends BasicAnnotationsTest { public BasicContextBasicAnnotationsUnitTestCase(String name) { - super(name); + super(name, true); } - protected MetaData setupEmpty() + protected MetaData setupMetaData(MetaDataLoader loader) { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); AbstractMetaDataContext context = new AbstractMetaDataContext(null, loader); return new MetaDataRetrievalToMetaDataBridge(context); } + protected MetaData setupEmpty() + { + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); + return setupMetaData(loader); + } + protected MetaData setupTestAnnotation() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addAnnotation(new TestAnnotationImpl()); - AbstractMetaDataContext context = new AbstractMetaDataContext(null, loader); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } protected MetaData setupTestAnnotation12() { - MemoryMetaDataLoader loader = new MemoryMetaDataLoader(); + MutableMetaDataLoader loader = createTestMutableMetaDataLoader(); loader.addAnnotation(new TestAnnotation1Impl()); loader.addAnnotation(new TestAnnotation2Impl()); - AbstractMetaDataContext context = new AbstractMetaDataContext(null, loader); - return new MetaDataRetrievalToMetaDataBridge(context); + return setupMetaData(loader); } } |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:29
|
User: adrian Date: 06/07/10 08:18:50 Modified: src/tests/org/jboss/test/metadata/context MetaDataContextAnnotationTest.java MetaDataContextMetaDataTest.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.2 +45 -55 container/src/tests/org/jboss/test/metadata/context/MetaDataContextAnnotationTest.java (In the diff below, changes in quantity of whitespace are not shown.) Index: MetaDataContextAnnotationTest.java =================================================================== RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/metadata/context/MetaDataContextAnnotationTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- MetaDataContextAnnotationTest.java 22 Jun 2006 14:57:26 -0000 1.1 +++ MetaDataContextAnnotationTest.java 10 Jul 2006 12:18:50 -0000 1.2 @@ -35,7 +35,7 @@ * MetaDataContextAnnotationTest. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public abstract class MetaDataContextAnnotationTest extends AbstractMetaDataContextMemoryLoaderTest { @@ -44,7 +44,7 @@ super(name); } - protected void testAnnotation(MetaData metaData, MutableMetaDataLoader loader) throws Exception + protected void testAnnotation(MetaData metaData, MutableMetaDataLoader loader, boolean local) throws Exception { ExpectedAnnotations expected = emptyExpectedAnnotations(); long last = metaData.getValidTime(); @@ -54,41 +54,39 @@ last = assertAddAnnotationNoPrevious(metaData, loader, annotation, expected, last); assertAnnotation(metaData, TestAnnotation.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); assertRemoveAnnotation(metaData, loader, TestAnnotation.class, expected, last, false); assertNoAnnotation(metaData, TestAnnotation.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); } public void testAnnotationFromFirstChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation(metaData, getFirstChild()); + testAnnotation(metaData, getFirstChild(), true); } public void testAnnotationFromSecondChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation(metaData, getSecondChild()); + testAnnotation(metaData, getSecondChild(), true); } public void testAnnotationFromFirstParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation(metaData, getFirstParent()); + testAnnotation(metaData, getFirstParent(), false); } public void testAnnotationFromSecondParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation(metaData, getSecondParent()); + testAnnotation(metaData, getSecondParent(), false); } - protected void testAnnotation12(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2) throws Exception + protected void testAnnotation12(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2, boolean local) throws Exception { ExpectedAnnotations expected = emptyExpectedAnnotations(); long last = metaData.getValidTime(); @@ -100,129 +98,125 @@ assertAnnotation(metaData, TestAnnotation1.class); assertNoAnnotation(metaData, TestAnnotation2.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); TestAnnotation2 annotation2 = new TestAnnotation2Impl(); last = assertAddAnnotationNoPrevious(metaData, loader2, annotation2, expected, last); assertAnnotation(metaData, TestAnnotation1.class); assertAnnotation(metaData, TestAnnotation2.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); assertRemoveAnnotation(metaData, loader1, TestAnnotation1.class, expected, last, false); assertNoAnnotation(metaData, TestAnnotation1.class); assertAnnotation(metaData, TestAnnotation2.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); assertRemoveAnnotation(metaData, loader2, TestAnnotation2.class, expected, last, false); assertNoAnnotation(metaData, TestAnnotation1.class); assertNoAnnotation(metaData, TestAnnotation2.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); } public void testAnnotation12FromFirstChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getFirstChild(), getFirstChild()); + testAnnotation12(metaData, getFirstChild(), getFirstChild(), true); } public void testAnnotation12FromFirstChildSecondChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getFirstChild(), getSecondChild()); + testAnnotation12(metaData, getFirstChild(), getSecondChild(), true); } public void testAnnotation12FromFirstChildFirstParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getFirstChild(), getFirstParent()); + testAnnotation12(metaData, getFirstChild(), getFirstParent(), false); } public void testAnnotation12FromFirstChildSecondParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getFirstChild(), getSecondParent()); + testAnnotation12(metaData, getFirstChild(), getSecondParent(), false); } public void testAnnotation12FromSecondChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getSecondChild(), getSecondChild()); + testAnnotation12(metaData, getSecondChild(), getSecondChild(), true); } public void testAnnotation12FromSecondChildFirstChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getSecondChild(), getFirstChild()); + testAnnotation12(metaData, getSecondChild(), getFirstChild(), true); } public void testAnnotation12FromSecondChildFirstParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getSecondChild(), getFirstParent()); + testAnnotation12(metaData, getSecondChild(), getFirstParent(), false); } public void testAnnotation12FromSecondChildSecondParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getSecondChild(), getSecondParent()); + testAnnotation12(metaData, getSecondChild(), getSecondParent(), false); } public void testAnnotation12FromFirstParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getFirstParent(), getFirstParent()); + testAnnotation12(metaData, getFirstParent(), getFirstParent(), false); } public void testAnnotation12FromFirstParentFirstChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getFirstParent(), getFirstChild()); + testAnnotation12(metaData, getFirstParent(), getFirstChild(), false); } public void testAnnotation12FromFirstParentSecondChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getFirstParent(), getSecondChild()); + testAnnotation12(metaData, getFirstParent(), getSecondChild(), false); } public void testAnnotation12FromFirstParentSecondParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getFirstParent(), getSecondParent()); + testAnnotation12(metaData, getFirstParent(), getSecondParent(), false); } public void testAnnotation12FromSecondParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getSecondParent(), getSecondParent()); + testAnnotation12(metaData, getSecondParent(), getSecondParent(), false); } public void testAnnotation12FromSecondParentFirstChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getSecondParent(), getFirstChild()); + testAnnotation12(metaData, getSecondParent(), getFirstChild(), false); } public void testAnnotation12FromSecondParentSecondChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getSecondParent(), getSecondChild()); + testAnnotation12(metaData, getSecondParent(), getSecondChild(), false); } public void testAnnotation12FromSecondParentFirstParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotation12(metaData, getSecondParent(), getFirstParent()); + testAnnotation12(metaData, getSecondParent(), getFirstParent(), false); } - protected void testAnnotationOverride(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2) throws Exception + protected void testAnnotationOverride(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2, boolean local) throws Exception { ExpectedAnnotations expected = emptyExpectedAnnotations(); long last = metaData.getValidTime(); @@ -232,98 +226,94 @@ last = assertAddAnnotationNoPrevious(metaData, loader1, annotation1, expected, last); assertAnnotation(metaData, TestAnnotation.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); TestAnnotation annotation2 = new TestAnnotationImpl(); last = assertAddAnnotationWithPrevious(metaData, loader2, annotation2, last); assertAnnotation(metaData, TestAnnotation.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); assertRemoveAnnotation(metaData, loader1, TestAnnotation.class, expected, last, true); assertAnnotation(metaData, TestAnnotation.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); assertRemoveAnnotation(metaData, loader2, TestAnnotation.class, expected, last, false); assertNoAnnotation(metaData, TestAnnotation.class); - assertAnnotations(metaData, expected); - assertAnnotationMetaDatas(metaData, expected); + assertAllAnnotations(metaData, expected, local); } public void testAnnotationOverrideFromFirstChildSecondChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getFirstChild(), getSecondChild()); + testAnnotationOverride(metaData, getFirstChild(), getSecondChild(), true); } public void testAnnotationOverrideFromFirstChildFirstParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getFirstChild(), getFirstParent()); + testAnnotationOverride(metaData, getFirstChild(), getFirstParent(), false); } public void testAnnotationOverrideFromFirstChildSecondParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getFirstChild(), getSecondParent()); + testAnnotationOverride(metaData, getFirstChild(), getSecondParent(), false); } public void testAnnotationOverrideFromSecondChildFirstChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getSecondChild(), getFirstChild()); + testAnnotationOverride(metaData, getSecondChild(), getFirstChild(), true); } public void testAnnotationOverrideFromSecondChildFirstParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getSecondChild(), getFirstParent()); + testAnnotationOverride(metaData, getSecondChild(), getFirstParent(), false); } public void testAnnotationOverrideFromSecondChildSecondParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getSecondChild(), getSecondParent()); + testAnnotationOverride(metaData, getSecondChild(), getSecondParent(), false); } public void testAnnotationOverrideFromFirstParentFirstChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getFirstParent(), getFirstChild()); + testAnnotationOverride(metaData, getFirstParent(), getFirstChild(), false); } public void testAnnotationOverrideFromFirstParentSecondChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getFirstParent(), getSecondChild()); + testAnnotationOverride(metaData, getFirstParent(), getSecondChild(), false); } public void testAnnotationOverrideFromFirstParentSecondParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getFirstParent(), getSecondParent()); + testAnnotationOverride(metaData, getFirstParent(), getSecondParent(), false); } public void testAnnotationOverrideFromSecondParentFirstChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getSecondParent(), getFirstChild()); + testAnnotationOverride(metaData, getSecondParent(), getFirstChild(), false); } public void testAnnotationOverrideFromSecondParentSecondChild() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getSecondParent(), getSecondChild()); + testAnnotationOverride(metaData, getSecondParent(), getSecondChild(), false); } public void testAnnotationOverrideFromSecondParentFirstParent() throws Exception { MetaData metaData = createTestContext(); - testAnnotationOverride(metaData, getSecondParent(), getFirstParent()); + testAnnotationOverride(metaData, getSecondParent(), getFirstParent(), false); } } 1.2 +90 -90 container/src/tests/org/jboss/test/metadata/context/MetaDataContextMetaDataTest.java (In the diff below, changes in quantity of whitespace are not shown.) Index: MetaDataContextMetaDataTest.java =================================================================== RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/metadata/context/MetaDataContextMetaDataTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- MetaDataContextMetaDataTest.java 22 Jun 2006 14:57:26 -0000 1.1 +++ MetaDataContextMetaDataTest.java 10 Jul 2006 12:18:50 -0000 1.2 @@ -35,7 +35,7 @@ * MetaDataContextMetaDataTest. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public abstract class MetaDataContextMetaDataTest extends AbstractMetaDataContextMemoryLoaderTest { @@ -44,7 +44,7 @@ super(name); } - protected void testMetaData(MetaData metaData, MutableMetaDataLoader loader) throws Exception + protected void testMetaData(MetaData metaData, MutableMetaDataLoader loader, boolean local) throws Exception { ExpectedMetaData expected = emptyExpectedMetaData(); long last = metaData.getValidTime(); @@ -54,39 +54,39 @@ last = assertAddMetaDataNoPrevious(metaData, loader, object, TestMetaData.class, expected, last); assertMetaData(metaData, TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader, TestMetaData.class, expected, last, false); assertNoMetaData(metaData, TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); } public void testMetaDataFromFirstChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData(metaData, getFirstChild()); + testMetaData(metaData, getFirstChild(), true); } public void testMetaDataFromSecondChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData(metaData, getSecondChild()); + testMetaData(metaData, getSecondChild(), true); } public void testMetaDataFromFirstParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData(metaData, getFirstParent()); + testMetaData(metaData, getFirstParent(), false); } public void testMetaDataFromSecondParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData(metaData, getSecondParent()); + testMetaData(metaData, getSecondParent(), false); } - protected void testMetaDataByName(MetaData metaData, MutableMetaDataLoader loader) throws Exception + protected void testMetaDataByName(MetaData metaData, MutableMetaDataLoader loader, boolean local) throws Exception { ExpectedMetaData expected = emptyExpectedMetaData(); long last = metaData.getValidTime(); @@ -96,39 +96,39 @@ last = assertAddMetaDataNoPrevious(metaData, loader, object, "Test", TestMetaData.class, expected, last); assertMetaData(metaData, "Test", TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader, "Test", TestMetaData.class, expected, last, false); assertNoMetaData(metaData, TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); } public void testMetaDataFromFirstChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataByName(metaData, getFirstChild()); + testMetaDataByName(metaData, getFirstChild(), true); } public void testMetaDataFromSecondChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataByName(metaData, getSecondChild()); + testMetaDataByName(metaData, getSecondChild(), true); } public void testMetaDataFromFirstParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataByName(metaData, getFirstParent()); + testMetaDataByName(metaData, getFirstParent(), false); } public void testMetaDataFromSecondParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataByName(metaData, getSecondParent()); + testMetaDataByName(metaData, getSecondParent(), false); } - protected void testMetaData12(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2) throws Exception + protected void testMetaData12(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2, boolean local) throws Exception { ExpectedMetaData expected = emptyExpectedMetaData(); long last = metaData.getValidTime(); @@ -140,125 +140,125 @@ assertMetaData(metaData, TestMetaData1.class); assertNoMetaData(metaData, TestMetaData2.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); TestMetaData2 object2 = new TestMetaData2Impl(); last = assertAddMetaDataNoPrevious(metaData, loader2, object2, TestMetaData2.class, expected, last); assertMetaData(metaData, TestMetaData1.class); assertMetaData(metaData, TestMetaData2.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader1, TestMetaData1.class, expected, last, false); assertNoMetaData(metaData, TestMetaData1.class); assertMetaData(metaData, TestMetaData2.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader2, TestMetaData2.class, expected, last, false); assertNoMetaData(metaData, TestMetaData1.class); assertNoMetaData(metaData, TestMetaData2.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); } public void testMetaData12FromFirstChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getFirstChild(), getFirstChild()); + testMetaData12(metaData, getFirstChild(), getFirstChild(), true); } public void testMetaData12FromFirstChildSecondChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getFirstChild(), getSecondChild()); + testMetaData12(metaData, getFirstChild(), getSecondChild(), true); } public void testMetaData12FromFirstChildFirstParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getFirstChild(), getFirstParent()); + testMetaData12(metaData, getFirstChild(), getFirstParent(), false); } public void testMetaData12FromFirstChildSecondParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getFirstChild(), getSecondParent()); + testMetaData12(metaData, getFirstChild(), getSecondParent(), false); } public void testMetaData12FromSecondChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getSecondChild(), getSecondChild()); + testMetaData12(metaData, getSecondChild(), getSecondChild(), true); } public void testMetaData12FromSecondChildFirstChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getSecondChild(), getFirstChild()); + testMetaData12(metaData, getSecondChild(), getFirstChild(), true); } public void testMetaData12FromSecondChildFirstParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getSecondChild(), getFirstParent()); + testMetaData12(metaData, getSecondChild(), getFirstParent(), false); } public void testMetaData12FromSecondChildSecondParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getSecondChild(), getSecondParent()); + testMetaData12(metaData, getSecondChild(), getSecondParent(), false); } public void testMetaData12FromFirstParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getFirstParent(), getFirstParent()); + testMetaData12(metaData, getFirstParent(), getFirstParent(), false); } public void testMetaData12FromFirstParentFirstChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getFirstParent(), getFirstChild()); + testMetaData12(metaData, getFirstParent(), getFirstChild(), false); } public void testMetaData12FromFirstParentSecondChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getFirstParent(), getSecondChild()); + testMetaData12(metaData, getFirstParent(), getSecondChild(), false); } public void testMetaData12FromFirstParentSecondParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getFirstParent(), getSecondParent()); + testMetaData12(metaData, getFirstParent(), getSecondParent(), false); } public void testMetaData12FromSecondParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getSecondParent(), getSecondParent()); + testMetaData12(metaData, getSecondParent(), getSecondParent(), false); } public void testMetaData12FromSecondParentFirstChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getSecondParent(), getFirstChild()); + testMetaData12(metaData, getSecondParent(), getFirstChild(), false); } public void testMetaData12FromSecondParentSecondChild() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getSecondParent(), getSecondChild()); + testMetaData12(metaData, getSecondParent(), getSecondChild(), false); } public void testMetaData12FromSecondParentFirstParent() throws Exception { MetaData metaData = createTestContext(); - testMetaData12(metaData, getSecondParent(), getFirstParent()); + testMetaData12(metaData, getSecondParent(), getFirstParent(), false); } - protected void testMetaData12ByName(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2) throws Exception + protected void testMetaData12ByName(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2, boolean local) throws Exception { ExpectedMetaData expected = emptyExpectedMetaData(); long last = metaData.getValidTime(); @@ -270,125 +270,125 @@ assertMetaData(metaData, "Test1", TestMetaData1.class); assertNoMetaData(metaData, "Test2", TestMetaData2.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); TestMetaData2 object2 = new TestMetaData2Impl(); last = assertAddMetaDataNoPrevious(metaData, loader2, object2, "Test2", TestMetaData2.class, expected, last); assertMetaData(metaData, "Test1", TestMetaData1.class); assertMetaData(metaData, "Test2", TestMetaData2.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader1, "Test1", TestMetaData1.class, expected, last, false); assertNoMetaData(metaData, "Test1", TestMetaData1.class); assertMetaData(metaData, "Test2", TestMetaData2.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader2, "Test2", TestMetaData2.class, expected, last, false); assertNoMetaData(metaData, "Test1", TestMetaData1.class); assertNoMetaData(metaData, "Test2", TestMetaData2.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); } public void testMetaData12FromFirstChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getFirstChild(), getFirstChild()); + testMetaData12ByName(metaData, getFirstChild(), getFirstChild(), true); } public void testMetaData12FromFirstChildSecondChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getFirstChild(), getSecondChild()); + testMetaData12ByName(metaData, getFirstChild(), getSecondChild(), true); } public void testMetaData12FromFirstChildFirstParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getFirstChild(), getFirstParent()); + testMetaData12ByName(metaData, getFirstChild(), getFirstParent(), false); } public void testMetaData12FromFirstChildSecondParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getFirstChild(), getSecondParent()); + testMetaData12ByName(metaData, getFirstChild(), getSecondParent(), false); } public void testMetaData12FromSecondChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getSecondChild(), getSecondChild()); + testMetaData12ByName(metaData, getSecondChild(), getSecondChild(), true); } public void testMetaData12FromSecondChildFirstChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getSecondChild(), getFirstChild()); + testMetaData12ByName(metaData, getSecondChild(), getFirstChild(), true); } public void testMetaData12FromSecondChildFirstParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getSecondChild(), getFirstParent()); + testMetaData12ByName(metaData, getSecondChild(), getFirstParent(), false); } public void testMetaData12FromSecondChildSecondParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getSecondChild(), getSecondParent()); + testMetaData12ByName(metaData, getSecondChild(), getSecondParent(), false); } public void testMetaData12FromFirstParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getFirstParent(), getFirstParent()); + testMetaData12ByName(metaData, getFirstParent(), getFirstParent(), false); } public void testMetaData12FromFirstParentFirstChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getFirstParent(), getFirstChild()); + testMetaData12ByName(metaData, getFirstParent(), getFirstChild(), false); } public void testMetaData12FromFirstParentSecondChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getFirstParent(), getSecondChild()); + testMetaData12ByName(metaData, getFirstParent(), getSecondChild(), false); } public void testMetaData12FromFirstParentSecondParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getFirstParent(), getSecondParent()); + testMetaData12ByName(metaData, getFirstParent(), getSecondParent(), false); } public void testMetaData12FromSecondParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getSecondParent(), getSecondParent()); + testMetaData12ByName(metaData, getSecondParent(), getSecondParent(), false); } public void testMetaData12FromSecondParentFirstChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getSecondParent(), getFirstChild()); + testMetaData12ByName(metaData, getSecondParent(), getFirstChild(), false); } public void testMetaData12FromSecondParentSecondChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getSecondParent(), getSecondChild()); + testMetaData12ByName(metaData, getSecondParent(), getSecondChild(), false); } public void testMetaData12FromSecondParentFirstParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaData12ByName(metaData, getSecondParent(), getFirstParent()); + testMetaData12ByName(metaData, getSecondParent(), getFirstParent(), false); } - protected void testMetaDataOverride(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2) throws Exception + protected void testMetaDataOverride(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2, boolean local) throws Exception { ExpectedMetaData expected = emptyExpectedMetaData(); long last = metaData.getValidTime(); @@ -398,98 +398,98 @@ last = assertAddMetaDataNoPrevious(metaData, loader1, object1, TestMetaData.class, expected, last); assertMetaData(metaData, TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); TestMetaData object2 = new TestMetaDataImpl(); last = assertAddMetaDataWithPrevious(metaData, loader2, object2, TestMetaData.class, last); assertMetaData(metaData, TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader1, TestMetaData.class, expected, last, true); assertMetaData(metaData, TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader2, TestMetaData.class, expected, last, false); assertNoMetaData(metaData, TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); } public void testMetaDataOverrideFromFirstChildSecondChild() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getFirstChild(), getSecondChild()); + testMetaDataOverride(metaData, getFirstChild(), getSecondChild(), true); } public void testMetaDataOverrideFromFirstChildFirstParent() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getFirstChild(), getFirstParent()); + testMetaDataOverride(metaData, getFirstChild(), getFirstParent(), false); } public void testMetaDataOverrideFromFirstChildSecondParent() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getFirstChild(), getSecondParent()); + testMetaDataOverride(metaData, getFirstChild(), getSecondParent(), false); } public void testMetaDataOverrideFromSecondChildFirstChild() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getSecondChild(), getFirstChild()); + testMetaDataOverride(metaData, getSecondChild(), getFirstChild(), true); } public void testMetaDataOverrideFromSecondChildFirstParent() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getSecondChild(), getFirstParent()); + testMetaDataOverride(metaData, getSecondChild(), getFirstParent(), false); } public void testMetaDataOverrideFromSecondChildSecondParent() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getSecondChild(), getSecondParent()); + testMetaDataOverride(metaData, getSecondChild(), getSecondParent(), false); } public void testMetaDataOverrideFromFirstParentFirstChild() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getFirstParent(), getFirstChild()); + testMetaDataOverride(metaData, getFirstParent(), getFirstChild(), false); } public void testMetaDataOverrideFromFirstParentSecondChild() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getFirstParent(), getSecondChild()); + testMetaDataOverride(metaData, getFirstParent(), getSecondChild(), false); } public void testMetaDataOverrideFromFirstParentSecondParent() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getFirstParent(), getSecondParent()); + testMetaDataOverride(metaData, getFirstParent(), getSecondParent(), false); } public void testMetaDataOverrideFromSecondParentFirstChild() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getSecondParent(), getFirstChild()); + testMetaDataOverride(metaData, getSecondParent(), getFirstChild(), false); } public void testMetaDataOverrideFromSecondParentSecondChild() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getSecondParent(), getSecondChild()); + testMetaDataOverride(metaData, getSecondParent(), getSecondChild(), false); } public void testMetaDataOverrideFromSecondParentFirstParent() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverride(metaData, getSecondParent(), getFirstParent()); + testMetaDataOverride(metaData, getSecondParent(), getFirstParent(), false); } - protected void testMetaDataOverrideByName(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2) throws Exception + protected void testMetaDataOverrideByName(MetaData metaData, MutableMetaDataLoader loader1, MutableMetaDataLoader loader2, boolean local) throws Exception { ExpectedMetaData expected = emptyExpectedMetaData(); long last = metaData.getValidTime(); @@ -499,94 +499,94 @@ last = assertAddMetaDataNoPrevious(metaData, loader1, object1, "Test", TestMetaData.class, expected, last); assertMetaData(metaData, "Test", TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); TestMetaData object2 = new TestMetaDataImpl(); last = assertAddMetaDataWithPrevious(metaData, loader2, object2, "Test", TestMetaData.class, last); assertMetaData(metaData, "Test", TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader1, "Test", TestMetaData.class, expected, last, true); assertMetaData(metaData, "Test", TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); assertRemoveMetaData(metaData, loader2, "Test", TestMetaData.class, expected, last, false); assertNoMetaData(metaData, "Test", TestMetaData.class); - assertMetaData(metaData, expected); + assertAllMetaData(metaData, expected, local); } public void testMetaDataOverrideFromFirstChildSecondChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getFirstChild(), getSecondChild()); + testMetaDataOverrideByName(metaData, getFirstChild(), getSecondChild(), true); } public void testMetaDataOverrideFromFirstChildFirstParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getFirstChild(), getFirstParent()); + testMetaDataOverrideByName(metaData, getFirstChild(), getFirstParent(), false); } public void testMetaDataOverrideFromFirstChildSecondParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getFirstChild(), getSecondParent()); + testMetaDataOverrideByName(metaData, getFirstChild(), getSecondParent(), false); } public void testMetaDataOverrideFromSecondChildFirstChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getSecondChild(), getFirstChild()); + testMetaDataOverrideByName(metaData, getSecondChild(), getFirstChild(), true); } public void testMetaDataOverrideFromSecondChildFirstParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getSecondChild(), getFirstParent()); + testMetaDataOverrideByName(metaData, getSecondChild(), getFirstParent(), false); } public void testMetaDataOverrideFromSecondChildSecondParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getSecondChild(), getSecondParent()); + testMetaDataOverrideByName(metaData, getSecondChild(), getSecondParent(), false); } public void testMetaDataOverrideFromFirstParentFirstChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getFirstParent(), getFirstChild()); + testMetaDataOverrideByName(metaData, getFirstParent(), getFirstChild(), false); } public void testMetaDataOverrideFromFirstParentSecondChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getFirstParent(), getSecondChild()); + testMetaDataOverrideByName(metaData, getFirstParent(), getSecondChild(), false); } public void testMetaDataOverrideFromFirstParentSecondParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getFirstParent(), getSecondParent()); + testMetaDataOverrideByName(metaData, getFirstParent(), getSecondParent(), false); } public void testMetaDataOverrideFromSecondParentFirstChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getSecondParent(), getFirstChild()); + testMetaDataOverrideByName(metaData, getSecondParent(), getFirstChild(), false); } public void testMetaDataOverrideFromSecondParentSecondChildByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getSecondParent(), getSecondChild()); + testMetaDataOverrideByName(metaData, getSecondParent(), getSecondChild(), false); } public void testMetaDataOverrideFromSecondParentFirstParentByName() throws Exception { MetaData metaData = createTestContext(); - testMetaDataOverrideByName(metaData, getSecondParent(), getFirstParent()); + testMetaDataOverrideByName(metaData, getSecondParent(), getFirstParent(), false); } } |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:23
|
User: adrian Date: 06/07/10 08:18:49 Modified: src/main/org/jboss/metadata/spi MetaData.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.2 +14 -0 container/src/main/org/jboss/metadata/spi/MetaData.java (In the diff below, changes in quantity of whitespace are not shown.) Index: MetaData.java =================================================================== RCS file: /cvsroot/jboss/container/src/main/org/jboss/metadata/spi/MetaData.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- MetaData.java 22 Jun 2006 14:57:30 -0000 1.1 +++ MetaData.java 10 Jul 2006 12:18:49 -0000 1.2 @@ -27,7 +27,7 @@ * MetaData. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public interface MetaData { @@ -60,6 +60,13 @@ Annotation[] getAnnotations(); /** + * Get all the local annotations + * + * @return the annotations + */ + Annotation[] getLocalAnnotations(); + + /** * Is the annotation present? * * @param annotationType the annotation type @@ -83,6 +90,13 @@ Object[] getMetaData(); /** + * Get all the local metadata + * + * @return the metadata + */ + Object[] getLocalMetaData(); + + /** * Is the metadata present * * @param type the type of the meta data |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:22
|
User: adrian Date: 06/07/10 08:18:51 Modified: src/main/org/jboss/metadata/plugins/loader/memory MemoryMetaDataLoader.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.2 +24 -0 container/src/main/org/jboss/metadata/plugins/loader/memory/MemoryMetaDataLoader.java (In the diff below, changes in quantity of whitespace are not shown.) Index: MemoryMetaDataLoader.java =================================================================== RCS file: /cvsroot/jboss/container/src/main/org/jboss/metadata/plugins/loader/memory/MemoryMetaDataLoader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- MemoryMetaDataLoader.java 22 Jun 2006 14:57:31 -0000 1.1 +++ MemoryMetaDataLoader.java 10 Jul 2006 12:18:50 -0000 1.2 @@ -37,12 +37,13 @@ import org.jboss.metadata.spi.retrieval.basic.BasicAnnotationsItem; import org.jboss.metadata.spi.retrieval.basic.BasicMetaDataItem; import org.jboss.metadata.spi.retrieval.basic.BasicMetaDatasItem; +import org.jboss.metadata.spi.scope.ScopeKey; /** * MemoryMetaDataLoader. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class MemoryMetaDataLoader extends AbstractMutableMetaDataLoader { @@ -81,6 +82,29 @@ this.cachable = cachable; } + /** + * Create a new MemoryMetaDataLoader. + * + * @param key the scope key + */ + public MemoryMetaDataLoader(ScopeKey scope) + { + this(scope, true, false); + } + + /** + * Create a new MemoryMetaDataLoader. + * + * @param key the scope key + * @param cachable whether items produced should be cachable + * @param restricted whether restricted items are allowed + */ + public MemoryMetaDataLoader(ScopeKey scope, boolean cachable, boolean restricted) + { + super(scope, restricted); + this.cachable = cachable; + } + public <T> boolean isCachable(Item<T> item) { return cachable; |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:14
|
User: adrian Date: 06/07/10 08:18:49 Added: src/main/org/jboss/metadata/spi/scope Scope.java ScopeLevel.java CommonLevels.java ScopeKey.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.1 date: 2006/07/10 12:18:49; author: adrian; state: Exp;container/src/main/org/jboss/metadata/spi/scope/Scope.java Index: Scope.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metadata.spi.scope; import java.io.Serializable; /** * Scope. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class Scope implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = 5255750644324593361L; /** The scope level */ private final ScopeLevel level; /** The scope qualifier */ private final String qualifier; public Scope(ScopeLevel level, String qualifier) { if (level == null) throw new IllegalArgumentException("Null level"); if (qualifier == null) throw new IllegalArgumentException("Null qualifier"); this.level = level; this.qualifier = qualifier; } public ScopeLevel getScopeLevel() { return level; } public String getQualifier() { return qualifier; } public String toString() { return level.getName() + "=" + qualifier; } public boolean equals(Object object) { if (object == this) return true; if (object == null || object instanceof Scope == false) return false; Scope other = (Scope) object; if (level.compareTo(other.getScopeLevel()) != 0) return false; return qualifier.equals(other.qualifier); } public int hashCode() { return level.hashCode(); } } 1.1 date: 2006/07/10 12:18:49; author: adrian; state: Exp;container/src/main/org/jboss/metadata/spi/scope/ScopeLevel.java Index: ScopeLevel.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metadata.spi.scope; import java.io.Serializable; import java.util.concurrent.ConcurrentHashMap; /** * ScopeLevel. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class ScopeLevel implements Serializable, Comparable<ScopeLevel> { /** The serialVersionUID */ private static final long serialVersionUID = 9090783215048463821L; /** The levels by name */ private static final ConcurrentHashMap<String, Integer> levelsByName = new ConcurrentHashMap<String, Integer>(); /** The scope level */ private final int level; /** The scope level name */ private final String name; /** * Get the scope level for a name * * @param name the name * @return the level or zero if no such level name */ public static int getScopeLevel(String name) { Integer result = levelsByName.get(name); if (result != null) return result; else return 0; } /** * Create a new ScopeLevel. * * @param level the level * @param name the name */ public ScopeLevel(int level, String name) { if (level <= 0) throw new IllegalArgumentException("Invalid level"); if (name == null) throw new IllegalArgumentException("Null name"); this.level = level; this.name = name; levelsByName.put(name, level); } public int getLevel() { return level; } public String getName() { return name; } public String toString() { return name; } public int compareTo(ScopeLevel o) { return level - o.level; } public boolean equals(Object object) { if (object == this) return true; if (object == null || object instanceof ScopeLevel == false) return false; ScopeLevel other = (ScopeLevel) object; return level == other.level; } public int hashCode() { return level; } } 1.1 date: 2006/07/10 12:18:49; author: adrian; state: Exp;container/src/main/org/jboss/metadata/spi/scope/CommonLevels.java Index: CommonLevels.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metadata.spi.scope; /** * CommonLevels. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public interface CommonLevels { /** The domain level name */ String DOMAIN_NAME = "DOMAIN"; /** The domain level */ ScopeLevel DOMAIN = new ScopeLevel(100, DOMAIN_NAME); /** The cluster level name */ String CLUSTER_NAME = "CLUSTER"; /** The cluster level */ ScopeLevel CLUSTER = new ScopeLevel(DOMAIN.getLevel() + 100, CLUSTER_NAME); /** The machine level name */ String MACHINE_NAME = "MACHINE"; /** The machine level */ ScopeLevel MACHINE = new ScopeLevel(CLUSTER.getLevel() + 100, MACHINE_NAME); /** The node level name */ String NODE_NAME = "NODE"; /** The node level */ ScopeLevel NODE = new ScopeLevel(MACHINE.getLevel() + 100, NODE_NAME); /** The jvm level name */ String JVM_NAME = "JVM"; /** The jvm level */ ScopeLevel JVM = new ScopeLevel(NODE.getLevel() + 100, JVM_NAME); /** The server level name */ String SERVER_NAME = "SERVER"; /** The server level */ ScopeLevel SERVER = new ScopeLevel(JVM.getLevel() + 100, SERVER_NAME); /** The subsystem level name */ String SUBSYSTEM_NAME = "SUBSYSTEM"; /** The subsystem level */ ScopeLevel SUBSYSTEM = new ScopeLevel(SERVER.getLevel() + 100, SUBSYSTEM_NAME); /** The application level name */ String APPLICATION_NAME = "APPLICATION"; /** The application level */ ScopeLevel APPLICATION = new ScopeLevel(SUBSYSTEM.getLevel() + 100, APPLICATION_NAME); /** The deployment level name */ String DEPLOYMENT_NAME = "DEPLOYMENT"; /** The deployment level */ ScopeLevel DEPLOYMENT = new ScopeLevel(APPLICATION.getLevel() + 100, DEPLOYMENT_NAME); /** The class level name */ String CLASS_NAME = "CLASS"; /** The class level */ ScopeLevel CLASS = new ScopeLevel(DEPLOYMENT.getLevel() + 100, CLASS_NAME); /** The instance level name */ String INSTANCE_NAME = "INSTANCE"; /** The instance level */ ScopeLevel INSTANCE = new ScopeLevel(CLASS.getLevel() + 100, INSTANCE_NAME); /** The join point level name */ String JOINPOINT_NAME = "JOINPOINT"; /** The join point level */ ScopeLevel JOINPOINT = new ScopeLevel(INSTANCE.getLevel() + 100, JOINPOINT_NAME); /** The join point override level name */ String JOINPOINT_OVERRIDE_NAME = "JOINPOINT_OVERRIDE"; /** The join point override level */ ScopeLevel JOINPOINT_OVERRIDE = new ScopeLevel(JOINPOINT.getLevel() + 100, JOINPOINT_OVERRIDE_NAME); /** The thread level name */ String THREAD_NAME = "THREAD"; /** The thread level */ ScopeLevel THREAD = new ScopeLevel(JOINPOINT_OVERRIDE.getLevel() + 100, THREAD_NAME); /** The unit of work level name */ String WORK_NAME = "WORK"; /** The unit of work level */ ScopeLevel WORK = new ScopeLevel(THREAD.getLevel() + 100, WORK_NAME); /** The request level name */ String REQUEST_NAME = "REQUEST"; /** The request level */ ScopeLevel REQUEST = new ScopeLevel(WORK.getLevel() + 100, REQUEST_NAME); } 1.1 date: 2006/07/10 12:18:49; author: adrian; state: Exp;container/src/main/org/jboss/metadata/spi/scope/ScopeKey.java Index: ScopeKey.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metadata.spi.scope; import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.SortedMap; import java.util.TreeMap; /** * ScopeKey. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class ScopeKey implements Serializable, Cloneable { /** The serialVersionUID */ private static final long serialVersionUID = -496238095349593371L; /** The default scope */ public static ScopeKey DEFAULT_SCOPE = new ScopeKey(new Scope(CommonLevels.JVM, "THIS")); /** The scopes */ private SortedMap<ScopeLevel, Scope> scopes = Collections.synchronizedSortedMap(new TreeMap<ScopeLevel, Scope>()); /** The scope level for this key */ private ScopeLevel maxScopeLevel; /** Whether the key is frozen */ private volatile boolean frozen = false; static { DEFAULT_SCOPE.freeze(); } /** * Create a new ScopeKey. */ public ScopeKey() { } /** * Create a new ScopeKey. * * @param scope the scope */ public ScopeKey(Scope scope) { addScope(scope); } /** * Create a new ScopeKey. * * @param level the scope level * @param qualifier the scope qualifier */ public ScopeKey(ScopeLevel level, String qualifier) { addScope(level, qualifier); } /** * Create a new ScopeKey. * * @param scopes the scopes */ public ScopeKey(Collection<Scope> scopes) { if (scopes == null) throw new IllegalArgumentException("Null scopes"); for (Scope scope : scopes) addScope(scope); } /** * Create a new ScopeKey. * * @param scopes the scopes */ public ScopeKey(Scope[] scopes) { if (scopes == null) throw new IllegalArgumentException("Null scopes"); for (Scope scope : scopes) addScope(scope); } /** * Get the frozen. * * @return the frozen. */ public boolean isFrozen() { return frozen; } /** * Set to frozen. */ public void freeze() { if (scopes.isEmpty()) throw new IllegalStateException("Attempt to freeze an empty key"); this.frozen = true; } /** * Get the scopes * * @return the scopes */ public Collection<Scope> getScopes() { return Collections.unmodifiableCollection(scopes.values()); } /** * Get the maximum scope level * * @return the largest scope level */ public ScopeLevel getMaxScopeLevel() { return maxScopeLevel; } /** * Get the parent scope key * * @return the parent or null if there is no parent */ public ScopeKey getParent() { if (scopes.size() < 2) return null; ScopeKey result = new ScopeKey(); for (Iterator<Scope> i = scopes.values().iterator(); i.hasNext();) { Scope scope = i.next(); if (i.hasNext()) result.addScope(scope); } return result; } public boolean isParent(ScopeKey key) { // The passed key doesn't have a parent if (key.scopes.size() < 2) return false; // If it is a child, it will have one more scope if (scopes.size() != key.scopes.size() - 1) return false; Iterator<Scope> thisScopes = scopes.values().iterator(); Iterator<Scope> keyScopes = key.scopes.values().iterator(); while (thisScopes.hasNext()) { Scope thisScope = thisScopes.next(); Scope keyScope = keyScopes.next(); if (thisScope.equals(keyScope) == false) return false; } return true; } /** * Add a scope * * @param scope the scope * @return the previous value or null if there wasn't one */ public Scope addScope(Scope scope) { if (scope == null) throw new IllegalArgumentException("Null scope"); if (frozen) throw new IllegalStateException("The scope key is frozen"); ScopeLevel level = scope.getScopeLevel(); Scope result = scopes.put(level, scope); if (maxScopeLevel == null || level.compareTo(maxScopeLevel) >= 0) maxScopeLevel = level; return result; } /** * Add a scope * * @param level the scope level * @param qualifier the scope qualifier * @return the previous value or null if there wasn't one */ public Scope addScope(ScopeLevel level, String qualifier) { Scope scope = new Scope(level, qualifier); return addScope(scope); } /** * Remove a scope * * @param scope the scope * @return the previous value or null if there wasn't one */ public Scope removeScope(Scope scope) { if (scope == null) throw new IllegalArgumentException("Null scope"); return removeScopeLevel(scope.getScopeLevel()); } /** * Get a scope level * * @param level the scope level * @return the scope or null if there is no such level */ public Scope getScopeLevel(ScopeLevel scopeLevel) { if (scopeLevel == null) throw new IllegalArgumentException("Null scope level"); return scopes.get(scopeLevel); } /** * Remove a scope level * * @param level the scope level * @return the scope or null if there is no such level */ public Scope removeScopeLevel(ScopeLevel scopeLevel) { if (scopeLevel == null) throw new IllegalArgumentException("Null scope level"); if (frozen) throw new IllegalStateException("The scope key is frozen"); Scope result = scopes.remove(scopeLevel); if (scopeLevel.equals(maxScopeLevel)) { maxScopeLevel = null; for (ScopeLevel level : scopes.keySet()) maxScopeLevel = level; } return result; } public String toString() { return scopes.values().toString(); } public boolean equals(Object object) { if (object == this) return true; if (object == null || object instanceof ScopeKey == false) return false; ScopeKey other = (ScopeKey) object; return scopes.equals(other.scopes); } public int hashCode() { return scopes.hashCode(); } protected ScopeKey clone() { try { return (ScopeKey) super.clone(); } catch (CloneNotSupportedException e) { throw new Error(e); } } } |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:13
|
User: adrian Date: 06/07/10 08:18:47 Added: src/tests/org/jboss/test/metadata/scope/test ScopeKeyUnitTestCase.java ScopeLevelUnitTestCase.java ScopeTestSuite.java ScopeUnitTestCase.java CommonLevelsUnitTestCase.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.1 date: 2006/07/10 12:18:47; author: adrian; state: Exp;container/src/tests/org/jboss/test/metadata/scope/test/ScopeKeyUnitTestCase.java Index: ScopeKeyUnitTestCase.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metadata.scope.test; import java.util.Collection; import java.util.HashSet; import org.jboss.metadata.spi.scope.Scope; import org.jboss.metadata.spi.scope.ScopeKey; import org.jboss.metadata.spi.scope.ScopeLevel; import org.jboss.test.metadata.AbstractMetaDataTest; /** * ScopeKeyUnitTestCase. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class ScopeKeyUnitTestCase extends AbstractMetaDataTest { private static ScopeLevel testLevel1 = new ScopeLevel(1, "ONE"); private static ScopeLevel testLevel2 = new ScopeLevel(2, "TWO"); private static ScopeLevel testLevel3 = new ScopeLevel(3, "THREE"); private static ScopeLevel testLevel4 = new ScopeLevel(4, "FOUR"); private static ScopeLevel testLevel5 = new ScopeLevel(5, "FIVE"); private static String testQualifier1 = "qualifier1"; private static String testQualifier1Different = "qualifier1Different"; private static String testQualifier2 = "qualifier2"; private static String testQualifier3 = "qualifier3"; private static String testQualifier3Different = "qualifier3Different"; private static String testQualifier4 = "qualifier4"; private static String testQualifier5 = "qualifier5"; private static Scope testScope1 = new Scope(testLevel1, testQualifier1); private static Scope testScope1Different = new Scope(testLevel1, testQualifier1Different); private static Scope testScope2 = new Scope(testLevel2, testQualifier2); private static Scope testScope3 = new Scope(testLevel3, testQualifier3); private static Scope testScope3Different = new Scope(testLevel3, testQualifier3Different); private static Scope testScope4 = new Scope(testLevel4, testQualifier4); private static Scope testScope5 = new Scope(testLevel5, testQualifier5); public ScopeKeyUnitTestCase(String name) { super(name); } public void testBasicScopeKeyConstructor() throws Exception { ScopeKey key = new ScopeKey(); Scope[] expected = new Scope[0]; assertScopeKey(expected, key); assertNull(key.getMaxScopeLevel()); } public void testSingleScopeKeyConstructor() throws Exception { ScopeKey key = new ScopeKey(testScope1); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); } public void testLevelQualifierScopeKeyConstructor() throws Exception { ScopeKey key = new ScopeKey(testLevel1, testQualifier1); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); } public void testCollectionScopeKeyConstructor() throws Exception { Scope[] expected = new Scope[] {}; HashSet<Scope> set = new HashSet<Scope>(); ScopeKey key = new ScopeKey(set); assertScopeKey(expected, key); expected = new Scope[] { testScope1 }; set = new HashSet<Scope>(); for (Scope scope : expected) set.add(scope); key = new ScopeKey(set); assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); expected = new Scope[] { testScope1, testScope2, testScope3, testScope4, testScope5 }; set = new HashSet<Scope>(); for (Scope scope : expected) set.add(scope); key = new ScopeKey(set); assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); } public void testCollectionScopeKeyConstructorSorts() throws Exception { Scope[] expected = new Scope[] { testScope1, testScope2, testScope3, testScope4, testScope5 }; HashSet<Scope> set = new HashSet<Scope>(); set.add(testScope2); set.add(testScope4); set.add(testScope5); set.add(testScope3); set.add(testScope1); ScopeKey key = new ScopeKey(set); assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); } public void testArrayScopeKeyConstructor() throws Exception { Scope[] expected = new Scope[] {}; ScopeKey key = new ScopeKey(expected); assertScopeKey(expected, key); expected = new Scope[] { testScope1 }; key = new ScopeKey(expected); assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); expected = new Scope[] { testScope1, testScope2, testScope3, testScope4, testScope5 }; key = new ScopeKey(expected); assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); } public void testArrayScopeKeyConstructorSorts() throws Exception { Scope[] expected = new Scope[] { testScope1, testScope2, testScope3, testScope4, testScope5 }; Scope[] array = new Scope[] { testScope5, testScope3, testScope1, testScope2, testScope4 }; ScopeKey key = new ScopeKey(array); assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScope() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testScope1, null); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); assertAddScope(key, testScope2, null); expected = new Scope[] { testScope1, testScope2 }; assertScopeKey(expected, key); assertEquals(testScope2.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScopeDuplicate() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testScope1, null); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); assertAddScope(key, testScope1, testScope1); assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScopeSorts() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testScope1, null); assertAddScope(key, testScope3, null); assertAddScope(key, testScope5, null); assertAddScope(key, testScope2, null); assertAddScope(key, testScope4, null); Scope[] expected = new Scope[] { testScope1, testScope2, testScope3, testScope4, testScope5 }; assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScopeChange() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testScope1, null); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); assertAddScope(key, testScope1Different, testScope1); expected = new Scope[] { testScope1Different }; assertScopeKey(expected, key); assertEquals(testScope1Different.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScopeChangeSorts() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testScope1, null); assertAddScope(key, testScope2, null); assertAddScope(key, testScope3, null); assertAddScope(key, testScope4, null); assertAddScope(key, testScope5, null); Scope[] expected = new Scope[] { testScope1, testScope2, testScope3, testScope4, testScope5 }; assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); assertAddScope(key, testScope3Different, testScope3); expected = new Scope[] { testScope1, testScope2, testScope3Different, testScope4, testScope5 }; assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScopeLevelQualifier() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testLevel1, testQualifier1, null); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); assertAddScope(key, testLevel2, testQualifier2, null); expected = new Scope[] { testScope1, testScope2 }; assertScopeKey(expected, key); assertEquals(testScope2.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScopeLevelQualifierDuplicate() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testLevel1, testQualifier1, null); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); assertAddScope(key, testLevel1, testQualifier1, testScope1); assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScopeLevelQualifierSorts() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testLevel4, testQualifier4, null); assertAddScope(key, testLevel2, testQualifier2, null); assertAddScope(key, testLevel1, testQualifier1, null); assertAddScope(key, testLevel3, testQualifier3, null); assertAddScope(key, testLevel5, testQualifier5, null); Scope[] expected = new Scope[] { testScope1, testScope2, testScope3, testScope4, testScope5 }; assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScopeLevelChange() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testLevel1, testQualifier1, null); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); assertAddScope(key, testLevel1, testQualifier1Different, testScope1); expected = new Scope[] { testScope1Different }; assertScopeKey(expected, key); assertEquals(testScope1Different.getScopeLevel(), key.getMaxScopeLevel()); } public void testAddScopeLevelChangeSorts() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testLevel1, testQualifier1, null); assertAddScope(key, testLevel2, testQualifier2, null); assertAddScope(key, testLevel3, testQualifier3, null); assertAddScope(key, testLevel4, testQualifier4, null); assertAddScope(key, testLevel5, testQualifier5, null); Scope[] expected = new Scope[] { testScope1, testScope2, testScope3, testScope4, testScope5 }; assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); assertAddScope(key, testLevel3, testQualifier3Different, testScope3); expected = new Scope[] { testScope1, testScope2, testScope3Different, testScope4, testScope5 }; assertScopeKey(expected, key); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); } public void testRemoveScope() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testScope1, null); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); assertRemoveScope(key, testScope1, testScope1); expected = new Scope[0]; assertScopeKey(expected, key); assertNull(key.getMaxScopeLevel()); } public void testRemoveScopeSorts() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testScope1, null); assertAddScope(key, testScope2, null); assertAddScope(key, testScope3, null); Scope[] expected = new Scope[] { testScope1, testScope2, testScope3 }; assertScopeKey(expected, key); assertEquals(testScope3.getScopeLevel(), key.getMaxScopeLevel()); assertRemoveScope(key, testScope2, testScope2); expected = new Scope[] { testScope1, testScope3 }; assertScopeKey(expected, key); assertEquals(testScope3.getScopeLevel(), key.getMaxScopeLevel()); } public void testRemoveScopeLevel() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testLevel1, testQualifier1, null); Scope[] expected = new Scope[] { testScope1 }; assertScopeKey(expected, key); assertEquals(testScope1.getScopeLevel(), key.getMaxScopeLevel()); assertRemoveScope(key, testLevel1, testScope1); expected = new Scope[0]; assertScopeKey(expected, key); assertNull(key.getMaxScopeLevel()); } public void testRemoveScopeLevelSorts() throws Exception { ScopeKey key = new ScopeKey(); assertAddScope(key, testLevel1, testQualifier1, null); assertAddScope(key, testLevel2, testQualifier2, null); assertAddScope(key, testLevel3, testQualifier3, null); Scope[] expected = new Scope[] { testScope1, testScope2, testScope3 }; assertScopeKey(expected, key); assertEquals(testScope3.getScopeLevel(), key.getMaxScopeLevel()); assertRemoveScope(key, testLevel2, testScope2); expected = new Scope[] { testScope1, testScope3 }; assertScopeKey(expected, key); assertEquals(testScope3.getScopeLevel(), key.getMaxScopeLevel()); } public void testFreeze() throws Exception { ScopeKey key = new ScopeKey(testScope1); key.freeze(); try { key.addScope(testScope1); fail("Should not be here!"); } catch (IllegalStateException expected) { } try { key.addScope(testLevel1, testQualifier1); fail("Should not be here!"); } catch (IllegalStateException expected) { } try { key.removeScope(testScope1); fail("Should not be here!"); } catch (IllegalStateException expected) { } try { key.removeScopeLevel(testLevel1); fail("Should not be here!"); } catch (IllegalStateException expected) { } } public void testNoParentEmpty() throws Exception { ScopeKey key = new ScopeKey(); ScopeKey parent = key.getParent(); assertNull(parent); } public void testNoParentSingleScope() throws Exception { ScopeKey key = new ScopeKey(); key.addScope(testScope1); ScopeKey parent = key.getParent(); assertNull(parent); } public void testSimpleParent() throws Exception { ScopeKey key = new ScopeKey(); key.addScope(testScope1); key.addScope(testScope2); ScopeKey parent = key.getParent(); assertNotNull(parent); ScopeKey expected = new ScopeKey(); expected.addScope(testScope1); assertEquals(expected, parent); assertEquals(testScope1.getScopeLevel(), parent.getMaxScopeLevel()); } public void testComplexParent() throws Exception { ScopeKey key = new ScopeKey(); key.addScope(testScope1); key.addScope(testScope2); key.addScope(testScope3); key.addScope(testScope4); key.addScope(testScope5); assertEquals(testScope5.getScopeLevel(), key.getMaxScopeLevel()); ScopeKey parent = key.getParent(); assertNotNull(parent); ScopeKey expected = new ScopeKey(); expected.addScope(testScope1); expected.addScope(testScope2); expected.addScope(testScope3); expected.addScope(testScope4); assertEquals(expected, parent); assertEquals(testScope4.getScopeLevel(), parent.getMaxScopeLevel()); parent = parent.getParent(); assertNotNull(parent); expected = new ScopeKey(); expected.addScope(testScope1); expected.addScope(testScope2); expected.addScope(testScope3); assertEquals(expected, parent); assertEquals(testScope3.getScopeLevel(), parent.getMaxScopeLevel()); parent = parent.getParent(); assertNotNull(parent); expected = new ScopeKey(); expected.addScope(testScope1); expected.addScope(testScope2); assertEquals(expected, parent); assertEquals(testScope2.getScopeLevel(), parent.getMaxScopeLevel()); parent = parent.getParent(); assertNotNull(parent); expected = new ScopeKey(); expected.addScope(testScope1); assertEquals(expected, parent); assertEquals(testScope1.getScopeLevel(), parent.getMaxScopeLevel()); parent = parent.getParent(); assertNull(parent); } public void testIsParentNoScopes() throws Exception { ScopeKey parent = new ScopeKey(testScope1); ScopeKey test = new ScopeKey(); assertFalse(parent.isParent(test)); } public void testIsParentSameScope() throws Exception { ScopeKey parent = new ScopeKey(testScope1); assertFalse(parent.isParent(parent)); ScopeKey test = new ScopeKey(testScope1); assertFalse(parent.isParent(test)); } public void testIsParentDifferentLevel() throws Exception { ScopeKey parent = new ScopeKey(testScope1); ScopeKey test = new ScopeKey(testScope2); assertFalse(parent.isParent(test)); } public void testIsParentDifferentQualifier() throws Exception { ScopeKey parent = new ScopeKey(testScope1); ScopeKey test = new ScopeKey(testScope1Different); assertFalse(parent.isParent(test)); } public void testIsParent() throws Exception { ScopeKey parent = new ScopeKey(testScope1); ScopeKey test = new ScopeKey(); test.addScope(testScope1); test.addScope(testScope2); assertTrue(parent.isParent(test)); test = new ScopeKey(); test.addScope(testScope1); test.addScope(testScope3); assertTrue(parent.isParent(test)); } public void testIsParentNotDirectly() throws Exception { ScopeKey parent = new ScopeKey(testScope1); ScopeKey test = new ScopeKey(); test.addScope(testScope1); test.addScope(testScope2); test.addScope(testScope3); assertFalse(parent.isParent(test)); } public void testIsParentNotChild() throws Exception { ScopeKey parent = new ScopeKey(); parent.addScope(testScope1); parent.addScope(testScope2); ScopeKey test = new ScopeKey(); test.addScope(testScope1); assertFalse(parent.isParent(test)); } public void testIsParentComplicated() throws Exception { ScopeKey parent = new ScopeKey(); parent.addScope(testScope1); parent.addScope(testScope2); parent.addScope(testScope3); parent.addScope(testScope4); ScopeKey test = new ScopeKey(); test.addScope(testScope1); test.addScope(testScope2); test.addScope(testScope3); test.addScope(testScope4); test.addScope(testScope5); assertTrue(parent.isParent(test)); } public void testEqualsEmpty() throws Exception { ScopeKey key1 = new ScopeKey(); ScopeKey key2 = new ScopeKey(); assertEquals(key1, key2); } public void testEqualsAfterAdd() throws Exception { ScopeKey key1 = new ScopeKey(); ScopeKey key2 = new ScopeKey(); assertAddScope(key1, testScope1, null); assertAddScope(key2, testScope1, null); assertAddScope(key1, testScope2, null); assertAddScope(key2, testScope2, null); assertAddScope(key1, testScope3, null); assertAddScope(key2, testScope3, null); assertEquals(key1, key2); } public void testEqualsAfterRemove() throws Exception { ScopeKey key1 = new ScopeKey(); ScopeKey key2 = new ScopeKey(); assertAddScope(key1, testScope1, null); assertAddScope(key2, testScope1, null); assertAddScope(key1, testScope2, null); assertAddScope(key2, testScope2, null); assertAddScope(key1, testScope3, null); assertAddScope(key2, testScope3, null); assertRemoveScope(key1, testScope2, testScope2); assertRemoveScope(key2, testScope2, testScope2); assertEquals(key1, key2); } public void testEqualsAfterReplace() throws Exception { ScopeKey key1 = new ScopeKey(); ScopeKey key2 = new ScopeKey(); assertAddScope(key1, testScope1, null); assertAddScope(key2, testScope1, null); assertAddScope(key1, testScope2, null); assertAddScope(key2, testScope2, null); assertAddScope(key1, testScope3, null); assertAddScope(key2, testScope3, null); assertAddScope(key1, testScope3Different, testScope3); assertAddScope(key2, testScope3Different, testScope3); assertEquals(key1, key2); } public void testNotEqualsAfterAdd() throws Exception { ScopeKey key1 = new ScopeKey(); ScopeKey key2 = new ScopeKey(); assertAddScope(key1, testScope1, null); assertAddScope(key2, testScope1, null); assertAddScope(key1, testScope2, null); assertAddScope(key2, testScope2, null); assertEquals(key1, key2); assertAddScope(key1, testScope3, null); assertFalse(key1.equals(key2)); } public void testNotEqualsAfterRemove() throws Exception { ScopeKey key1 = new ScopeKey(); ScopeKey key2 = new ScopeKey(); assertAddScope(key1, testScope1, null); assertAddScope(key2, testScope1, null); assertAddScope(key1, testScope2, null); assertAddScope(key2, testScope2, null); assertAddScope(key1, testScope3, null); assertAddScope(key2, testScope3, null); assertEquals(key1, key2); assertRemoveScope(key1, testScope2, testScope2); assertFalse(key1.equals(key2)); } public void testNotEqualsAfterReplace() throws Exception { ScopeKey key1 = new ScopeKey(); ScopeKey key2 = new ScopeKey(); assertAddScope(key1, testScope1, null); assertAddScope(key2, testScope1, null); assertAddScope(key1, testScope2, null); assertAddScope(key2, testScope2, null); assertAddScope(key1, testScope3, null); assertAddScope(key2, testScope3, null); assertEquals(key1, key2); assertAddScope(key1, testScope3Different, testScope3); assertFalse(key1.equals(key2)); } protected void assertScopeKey(Scope[] scopes, ScopeKey key) throws Exception { assertNotNull(scopes); assertNotNull(key); Collection<Scope> result = key.getScopes(); assertEquals(scopes.length, result.size()); int index = 0; for (Scope scope : result) assertEquals(scopes[index++], scope); } protected void assertAddScope(ScopeKey key, Scope add, Scope expected) throws Exception { Scope previous = key.addScope(add); assertEquals(expected, previous); } protected void assertRemoveScope(ScopeKey key, Scope remove, Scope expected) throws Exception { Scope previous = key.removeScope(remove); assertEquals(expected, previous); } protected void assertAddScope(ScopeKey key, ScopeLevel level, String qualifier, Scope expected) throws Exception { Scope previous = key.addScope(level, qualifier); assertEquals(expected, previous); } protected void assertRemoveScope(ScopeKey key, ScopeLevel level, Scope expected) throws Exception { Scope previous = key.removeScopeLevel(level); assertEquals(expected, previous); } } 1.1 date: 2006/07/10 12:18:47; author: adrian; state: Exp;container/src/tests/org/jboss/test/metadata/scope/test/ScopeLevelUnitTestCase.java Index: ScopeLevelUnitTestCase.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metadata.scope.test; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import org.jboss.metadata.spi.scope.ScopeLevel; import org.jboss.test.metadata.AbstractMetaDataTest; /** * ScopeUnitTestCase. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class ScopeLevelUnitTestCase extends AbstractMetaDataTest { public ScopeLevelUnitTestCase(String name) { super(name); } public void testBasicScopeLevel() throws Exception { ScopeLevel test = new ScopeLevel(99, "HELLO"); assertEquals(99, test.getLevel()); assertEquals("HELLO", test.getName()); assertEquals(99, test.hashCode()); assertEquals("HELLO", test.toString()); } public void testScopeLevelEquals() throws Exception { ScopeLevel test1 = new ScopeLevel(1, "HELLO"); ScopeLevel test2 = new ScopeLevel(1, "HELLO"); assertEquals(test1, test2); ScopeLevel test3 = new ScopeLevel(1, "DIFFERENT"); assertEquals(test1, test3); } public void testScopeLevelNotEquals() throws Exception { ScopeLevel test1 = new ScopeLevel(1, "HELLO"); ScopeLevel test2 = new ScopeLevel(2, "HELLO"); assertFalse(test1.equals(test2)); } public void testScopeLevelSerialization() throws Exception { ScopeLevel test1 = new ScopeLevel(99, "HELLO"); byte[] bytes = serialize(test1); ScopeLevel test2 = (ScopeLevel) deserialize(bytes); assertEquals(99, test2.getLevel()); assertEquals("HELLO", test2.getName()); assertEquals(99, test2.hashCode()); assertEquals("HELLO", test2.toString()); assertEquals(test1, test2); } public void testScopeLevelComparison() throws Exception { ScopeLevel test1 = new ScopeLevel(1, "HELLO"); ScopeLevel test2 = new ScopeLevel(2, "HELLO"); assertTrue(test1.compareTo(test2) < 0); assertTrue(test2.compareTo(test1) > 0); ScopeLevel test3 = new ScopeLevel(3, "HELLO"); assertTrue(test1.compareTo(test3) < 0); assertTrue(test3.compareTo(test1) > 0); assertTrue(test2.compareTo(test3) < 0); assertTrue(test3.compareTo(test2) > 0); ScopeLevel test4 = new ScopeLevel(1, "HELLO"); assertTrue(test1.compareTo(test4) == 0); ScopeLevel test5 = new ScopeLevel(1, "DIFFERENT"); assertTrue(test1.compareTo(test5) == 0); } public void testScopeLevelSetBehaviourDuplicates() throws Exception { HashSet<ScopeLevel> set = new HashSet<ScopeLevel>(); ScopeLevel test1 = new ScopeLevel(1, "HELLO"); set.add(test1); checkSet(set); ScopeLevel test2 = new ScopeLevel(1, "HELLO"); set.add(test2); checkSet(set); ScopeLevel test3 = new ScopeLevel(1, "DIFFERENT"); set.add(test3); checkSet(set); } protected void checkSet(HashSet<ScopeLevel> set) throws Exception { assertEquals(1, set.size()); ScopeLevel test = set.iterator().next(); assertEquals(1, test.getLevel()); assertEquals("HELLO", test.getName()); } public void testScopeLevelSet() throws Exception { LinkedHashSet<ScopeLevel> set = new LinkedHashSet<ScopeLevel>(); ScopeLevel test1 = new ScopeLevel(1, "HELLO"); set.add(test1); ScopeLevel test2 = new ScopeLevel(2, "HELLO"); set.add(test2); ScopeLevel test3 = new ScopeLevel(3, "DIFFERENT"); set.add(test3); assertEquals(3, set.size()); Iterator<ScopeLevel> i = set.iterator(); ScopeLevel test = i.next(); assertEquals(1, test.getLevel()); assertEquals("HELLO", test.getName()); test = i.next(); assertEquals(2, test.getLevel()); assertEquals("HELLO", test.getName()); test = i.next(); assertEquals(3, test.getLevel()); assertEquals("DIFFERENT", test.getName()); } public void testScopeLevelMapBehaviourDuplicates() throws Exception { HashMap<ScopeLevel, Object> map = new HashMap<ScopeLevel, Object>(); ScopeLevel test1 = new ScopeLevel(1, "HELLO"); map.put(test1, new Object()); checkMap(map); ScopeLevel test2 = new ScopeLevel(1, "HELLO"); map.put(test2, new Object()); checkMap(map); ScopeLevel test3 = new ScopeLevel(1, "DIFFERENT"); map.put(test3, new Object()); checkMap(map); } protected void checkMap(HashMap<ScopeLevel, Object> map) throws Exception { assertEquals(1, map.size()); ScopeLevel test = map.keySet().iterator().next(); assertEquals(1, test.getLevel()); assertEquals("HELLO", test.getName()); } public void testScopeLevelMap() throws Exception { LinkedHashMap<ScopeLevel, Object> map = new LinkedHashMap<ScopeLevel, Object>(); ScopeLevel test1 = new ScopeLevel(1, "HELLO"); Object object1 = new Object(); map.put(test1, object1); ScopeLevel test2 = new ScopeLevel(2, "HELLO"); Object object2 = new Object(); map.put(test2, object2); ScopeLevel test3 = new ScopeLevel(3, "DIFFERENT"); Object object3 = new Object(); map.put(test3, object3); assertEquals(3, map.size()); Iterator<ScopeLevel> i = map.keySet().iterator(); ScopeLevel test = i.next(); assertEquals(1, test.getLevel()); assertEquals("HELLO", test.getName()); test = i.next(); assertEquals(2, test.getLevel()); assertEquals("HELLO", test.getName()); test = i.next(); assertEquals(3, test.getLevel()); assertEquals("DIFFERENT", test.getName()); } } 1.1 date: 2006/07/10 12:18:47; author: adrian; state: Exp;container/src/tests/org/jboss/test/metadata/scope/test/ScopeTestSuite.java Index: ScopeTestSuite.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metadata.scope.test; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; /** * ScopeTestSuite. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class ScopeTestSuite extends TestSuite { public static void main(String[] args) { TestRunner.run(suite()); } public static Test suite() { TestSuite suite = new TestSuite("Scope Tests"); suite.addTest(new TestSuite(ScopeLevelUnitTestCase.class)); suite.addTest(new TestSuite(CommonLevelsUnitTestCase.class)); suite.addTest(new TestSuite(ScopeUnitTestCase.class)); suite.addTest(new TestSuite(ScopeKeyUnitTestCase.class)); return suite; } } 1.1 date: 2006/07/10 12:18:47; author: adrian; state: Exp;container/src/tests/org/jboss/test/metadata/scope/test/ScopeUnitTestCase.java Index: ScopeUnitTestCase.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metadata.scope.test; import org.jboss.metadata.spi.scope.Scope; import org.jboss.metadata.spi.scope.ScopeLevel; import org.jboss.test.metadata.AbstractMetaDataTest; /** * ScopeUnitTestCase. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class ScopeUnitTestCase extends AbstractMetaDataTest { private static ScopeLevel testLevel1 = new ScopeLevel(1, "TEST"); private static ScopeLevel testLevel2 = new ScopeLevel(2, "TEST"); public ScopeUnitTestCase(String name) { super(name); } public void testBasicScope() throws Exception { Scope test = new Scope(testLevel1, "localhost"); assertEquals(testLevel1, test.getScopeLevel()); assertEquals("localhost", test.getQualifier()); } public void testScopeEquals() throws Exception { Scope test1 = new Scope(testLevel1, "localhost"); Scope test2 = new Scope(testLevel1, "localhost"); assertEquals(test1, test2); } public void testScopeNotEquals() throws Exception { Scope test1 = new Scope(testLevel1, "localhost"); Scope test2 = new Scope(testLevel1, "remotehost"); assertFalse(test1.equals(test2)); Scope test3 = new Scope(testLevel2, "localhost"); assertFalse(test1.equals(test3)); } public void testScopeSerialization() throws Exception { Scope test1 = new Scope(testLevel1, "localhost"); byte[] bytes = serialize(test1); Scope test2 = (Scope) deserialize(bytes); assertEquals(testLevel1, test2.getScopeLevel()); assertEquals("localhost", test2.getQualifier()); assertEquals(test1, test2); } } 1.1 date: 2006/07/10 12:18:47; author: adrian; state: Exp;container/src/tests/org/jboss/test/metadata/scope/test/CommonLevelsUnitTestCase.java Index: CommonLevelsUnitTestCase.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.test.metadata.scope.test; import java.util.TreeSet; import org.jboss.metadata.spi.scope.CommonLevels; import org.jboss.metadata.spi.scope.ScopeLevel; import org.jboss.test.metadata.AbstractMetaDataTest; /** * CommonLevelsUnitTestCase. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public class CommonLevelsUnitTestCase extends AbstractMetaDataTest { public CommonLevelsUnitTestCase(String name) { super(name); } public void testCommonLevels() throws Exception { ScopeLevel[] commonLevels = new ScopeLevel[] { CommonLevels.DOMAIN, CommonLevels.CLUSTER, CommonLevels.MACHINE, CommonLevels.NODE, CommonLevels.JVM, CommonLevels.SERVER, CommonLevels.SUBSYSTEM, CommonLevels.APPLICATION, CommonLevels.DEPLOYMENT, CommonLevels.CLASS, CommonLevels.INSTANCE, CommonLevels.JOINPOINT, CommonLevels.JOINPOINT_OVERRIDE, CommonLevels.THREAD, CommonLevels.WORK, CommonLevels.REQUEST, }; int lastLevel = 0; String lastName = ""; for (ScopeLevel level : commonLevels) { assertTrue(level.getLevel() - lastLevel == 100); assertFalse(lastName.equals(level.getName())); lastLevel = level.getLevel(); lastName = level.getName(); } TreeSet<ScopeLevel> set = new TreeSet<ScopeLevel>(); for (ScopeLevel level : commonLevels) set.add(level); assertTrue(commonLevels.length == set.size()); int index = 0; for (ScopeLevel level : set) assertTrue(commonLevels[index++] == level); } } |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:13
|
User: adrian Date: 06/07/10 08:18:49 Added: src/main/org/jboss/metadata/plugins/repository AbstractMetaDataRepository.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.1 date: 2006/07/10 12:18:49; author: adrian; state: Exp;container/src/main/org/jboss/metadata/plugins/repository/AbstractMetaDataRepository.java Index: AbstractMetaDataRepository.java =================================================================== /* * JBoss, Home of Professional Open Source * Copyright 2006, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.metadata.plugins.repository; import org.jboss.metadata.spi.MetaData; import org.jboss.metadata.spi.repository.MetaDataRepository; import org.jboss.metadata.spi.retrieval.MetaDataRetrieval; import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge; import org.jboss.metadata.spi.scope.ScopeKey; /** * AbstractMetaDataRepository. * * @author <a href="ad...@jb...">Adrian Brock</a> * @version $Revision: 1.1 $ */ public abstract class AbstractMetaDataRepository implements MetaDataRepository { public MetaData getMetaData(ScopeKey key) { MetaDataRetrieval retrieval = getMetaDataRetrieval(key); if (retrieval == null) return null; return new MetaDataRetrievalToMetaDataBridge(retrieval); } } |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:13
|
User: adrian Date: 06/07/10 08:18:49 Modified: src/main/org/jboss/metadata/plugins/loader/reflection AnnotatedElementMetaDataLoader.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.2 +25 -0 container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java (In the diff below, changes in quantity of whitespace are not shown.) Index: AnnotatedElementMetaDataLoader.java =================================================================== RCS file: /cvsroot/jboss/container/src/main/org/jboss/metadata/plugins/loader/reflection/AnnotatedElementMetaDataLoader.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- AnnotatedElementMetaDataLoader.java 22 Jun 2006 14:57:29 -0000 1.1 +++ AnnotatedElementMetaDataLoader.java 10 Jul 2006 12:18:49 -0000 1.2 @@ -23,12 +23,16 @@ import java.lang.annotation.Annotation; import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Member; import org.jboss.metadata.plugins.loader.BasicMetaDataLoader; import org.jboss.metadata.spi.retrieval.AnnotationItem; import org.jboss.metadata.spi.retrieval.AnnotationsItem; import org.jboss.metadata.spi.retrieval.simple.SimpleAnnotationItem; import org.jboss.metadata.spi.retrieval.simple.SimpleAnnotationsItem; +import org.jboss.metadata.spi.scope.CommonLevels; +import org.jboss.metadata.spi.scope.Scope; +import org.jboss.metadata.spi.scope.ScopeKey; import org.jboss.util.JBossStringBuilder; import org.jboss.util.Strings; @@ -36,13 +40,33 @@ * AnnotatedElementMetaDataLoader. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class AnnotatedElementMetaDataLoader extends BasicMetaDataLoader { /** The annotated element */ private AnnotatedElement annotated; + private static final ScopeKey getScopeKey(AnnotatedElement annotated) + { + Scope scope = null; + if (annotated instanceof Class) + { + Class clazz = (Class) annotated; + scope = new Scope(CommonLevels.CLASS, clazz.getName()); + } + else if (annotated instanceof Member) + { + Member member = (Member) annotated; + scope = new Scope(CommonLevels.JOINPOINT, member.getName()); + } + else + { + return ScopeKey.DEFAULT_SCOPE; + } + return new ScopeKey(scope); + } + /** * Create a new AnnotatedElementMetaDataContext. * @@ -50,6 +74,7 @@ */ public AnnotatedElementMetaDataLoader(AnnotatedElement annotated) { + super(getScopeKey(annotated)); if (annotated == null) throw new IllegalArgumentException("Null annotated element"); this.annotated = annotated; |
From: Adrian B. <adr...@jb...> - 2006-07-10 12:48:10
|
User: adrian Date: 06/07/10 08:18:49 Modified: src/tests/org/jboss/test/metadata AbstractMetaDataTest.java MetaDataAllTestSuite.java Log: [JBMICROCONT-70] - Scoped metadata and basic repository Revision Changes Path 1.2 +283 -0 container/src/tests/org/jboss/test/metadata/AbstractMetaDataTest.java (In the diff below, changes in quantity of whitespace are not shown.) Index: AbstractMetaDataTest.java =================================================================== RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/metadata/AbstractMetaDataTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- AbstractMetaDataTest.java 22 Jun 2006 14:57:30 -0000 1.1 +++ AbstractMetaDataTest.java 10 Jul 2006 12:18:49 -0000 1.2 @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.List; +import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader; import org.jboss.metadata.spi.MetaData; import org.jboss.metadata.spi.MutableMetaData; import org.jboss.metadata.spi.loader.MutableMetaDataLoader; @@ -34,6 +35,7 @@ import org.jboss.metadata.spi.retrieval.MetaDataItem; import org.jboss.metadata.spi.retrieval.MetaDataRetrieval; import org.jboss.metadata.spi.retrieval.MetaDatasItem; +import org.jboss.metadata.spi.scope.ScopeKey; import org.jboss.test.BaseTestCase; import org.jboss.test.metadata.shared.support.ExpectedAnnotations; import org.jboss.test.metadata.shared.support.ExpectedMetaData; @@ -42,7 +44,7 @@ * AbstractMetaDataTest. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class AbstractMetaDataTest extends BaseTestCase { @@ -72,6 +74,27 @@ } /** + * Create a test mutable meta data loader + * + * @return the implementation + */ + public MutableMetaDataLoader createTestMutableMetaDataLoader() + { + return new MemoryMetaDataLoader(); + } + + /** + * Create a test mutable meta data loader + * + * @param key the scope key + * @return the implementation + */ + public MutableMetaDataLoader createTestMutableMetaDataLoader(ScopeKey key) + { + return new MemoryMetaDataLoader(key); + } + + /** * Assert an annotation * * @param metaData the meta data @@ -1484,6 +1507,34 @@ } /** + * Check the annotations from all retrieval methods + * + * @param metaData the meta data + * @param expected the expected annotation classes + */ + protected void assertAllAnnotations(MetaData metaData, ExpectedAnnotations expected) throws Exception + { + assertAllAnnotations(metaData, expected, true); + } + + /** + * Check the annotations from all retrieval methods + * + * @param metaData the meta data + * @param expected the expected annotation classes + * @param local whether to test the local annotations + */ + protected void assertAllAnnotations(MetaData metaData, ExpectedAnnotations expected, boolean local) throws Exception + { + assertAnnotations(metaData, expected); + if (local) + assertLocalAnnotations(metaData, expected); + assertAnnotationMetaDatas(metaData, expected); + if (local) + assertLocalAnnotationMetaDatas(metaData, expected); + } + + /** * Check the annotations * * @param metaData the meta data @@ -1507,6 +1558,57 @@ } /** + * Check the local annotations + * + * @param metaData the meta data + * @param expected the expected annotation classes + */ + protected void assertLocalAnnotations(MetaData metaData, ExpectedAnnotations expected) throws Exception + { + assertNotNull(metaData); + assertNotNull(expected); + + Annotation[] result = metaData.getLocalAnnotations(); + assertNotNull("Null result", result); + ExpectedAnnotations actual = emptyExpectedAnnotations(); + for (Annotation annotation : result) + { + assertNotNull("Null annotation " + Arrays.asList(result), annotation); + actual.add(annotation.annotationType()); + } + + assertExpectedAnnotations("Annotations", expected, actual); + } + + /** + * Check the annotations from all retrieval methods + * + * @param metaData the retrieval + * @param expected the expected annotation classes + */ + protected void assertAllAnnotations(MetaDataRetrieval metaData, ExpectedAnnotations expected) throws Exception + { + assertAllAnnotations(metaData, expected, true); + } + + /** + * Check the annotations from all retrieval methods + * + * @param metaData the retrieval + * @param expected the expected annotation classes + * @param local whether to test the local annotations + */ + protected void assertAllAnnotations(MetaDataRetrieval metaData, ExpectedAnnotations expected, boolean local) throws Exception + { + assertAnnotations(metaData, expected); + if (local) + assertLocalAnnotations(metaData, expected); + assertAnnotationMetaDatas(metaData, expected); + if (local) + assertLocalAnnotationMetaDatas(metaData, expected); + } + + /** * Check the annotations * * @param metaData the retrieval @@ -1534,6 +1636,58 @@ } /** + * Check the local annotations + * + * @param metaData the retrieval + * @param expected the expected annotation classes + */ + protected void assertLocalAnnotations(MetaDataRetrieval metaData, ExpectedAnnotations expected) throws Exception + { + assertNotNull(metaData); + assertNotNull(expected); + + AnnotationsItem result = metaData.retrieveLocalAnnotations(); + assertNotNull("Null result", result); + AnnotationItem[] items = result.getAnnotations(); + assertNotNull("Null items", items); + ExpectedAnnotations actual = emptyExpectedAnnotations(); + for (AnnotationItem item : items) + { + assertNotNull("Null annotation item " + Arrays.asList(items), item); + Annotation annotation = item.getAnnotation(); + assertNotNull("Null annotation " + Arrays.asList(items), annotation); + actual.add(annotation.annotationType()); + } + + assertExpectedAnnotations("Annotations", expected, actual); + } + + /** + * Check the meta data from all retrieval methods + * + * @param metaData the meta data + * @param expected the expected types + */ + protected void assertAllMetaData(MetaData metaData, ExpectedMetaData expected) throws Exception + { + assertAllMetaData(metaData, expected, true); + } + + /** + * Check the meta data from all retrieval methods + * + * @param metaData the meta data + * @param expected the expected types + * @param local whether to include the local meta data + */ + protected void assertAllMetaData(MetaData metaData, ExpectedMetaData expected, boolean local) throws Exception + { + assertMetaData(metaData, expected); + if (local) + assertLocalMetaData(metaData, expected); + } + + /** * Check the meta data * * @param metaData the meta data @@ -1557,6 +1711,54 @@ } /** + * Check the local meta data + * + * @param metaData the meta data + * @param expected the expected types + */ + protected void assertLocalMetaData(MetaData metaData, ExpectedMetaData expected) throws Exception + { + assertNotNull(metaData); + assertNotNull(expected); + + Object[] result = metaData.getLocalMetaData(); + assertNotNull("Null result", result); + ExpectedMetaData actual = emptyExpectedMetaData(); + for (Object object : result) + { + assertNotNull("Null object " + Arrays.asList(result), object); + actual.add(getType(object)); + } + + assertExpectedMetaData("MetaData", expected, actual); + } + + /** + * Check the meta data from all retrieval methods + * + * @param metaData the retrieval + * @param expected the expected types + */ + protected void assertAllMetaData(MetaDataRetrieval metaData, ExpectedMetaData expected) throws Exception + { + assertAllMetaData(metaData, expected, true); + } + + /** + * Check the meta data from all retrieval methods + * + * @param metaData the retrieval + * @param expected the expected types + * @param local whether to include the local meta data + */ + protected void assertAllMetaData(MetaDataRetrieval metaData, ExpectedMetaData expected, boolean local) throws Exception + { + assertMetaData(metaData, expected); + if (local) + assertLocalMetaData(metaData, expected); + } + + /** * Check the meta data * * @param metaData the retrieval @@ -1584,6 +1786,33 @@ } /** + * Check the local meta data + * + * @param metaData the retrieval + * @param expected the expected types + */ + protected void assertLocalMetaData(MetaDataRetrieval metaData, ExpectedMetaData expected) throws Exception + { + assertNotNull(metaData); + assertNotNull(expected); + + MetaDatasItem result = metaData.retrieveLocalMetaData(); + assertNotNull("Null result", result); + MetaDataItem[] items = result.getMetaDatas(); + assertNotNull("Null items", items); + ExpectedMetaData actual = emptyExpectedMetaData(); + for (MetaDataItem item : items) + { + assertNotNull("Null meta data item " + Arrays.asList(items), item); + Object object = item.getValue(); + assertNotNull("Null object " + Arrays.asList(items), object); + actual.add(getType(object)); + } + + assertExpectedMetaData("MetaData", expected, actual); + } + + /** * Get the type for the object * * @param object the object @@ -1624,6 +1853,31 @@ } /** + * Check the local meta data + * + * @param metaData the meta data + * @param expected the expected annotation classes + */ + protected void assertLocalAnnotationMetaDatas(MetaData metaData, ExpectedAnnotations expected) throws Exception + { + assertNotNull(metaData); + assertNotNull(expected); + + Object[] result = metaData.getLocalMetaData(); + assertNotNull("Null result", result); + ExpectedAnnotations actual = emptyExpectedAnnotations(); + for (Object object : result) + { + assertNotNull("Null annotation " + Arrays.asList(result), object); + assertTrue("Not an annotation " + Arrays.asList(result), object instanceof Annotation); + Annotation annotation = (Annotation) object; + actual.add(annotation.annotationType()); + } + + assertExpectedAnnotations("AnnotationMetaDatas", expected, actual); + } + + /** * Check the meta data * * @param metaData the retrieval @@ -1653,6 +1907,35 @@ } /** + * Check the local meta data + * + * @param metaData the retrieval + * @param expected the expected annotation classes + */ + protected void assertLocalAnnotationMetaDatas(MetaDataRetrieval metaData, ExpectedAnnotations expected) throws Exception + { + assertNotNull(metaData); + assertNotNull(expected); + + MetaDatasItem result = metaData.retrieveLocalMetaData(); + assertNotNull("Null result", result); + MetaDataItem[] items = result.getMetaDatas(); + assertNotNull("Null items", items); + ExpectedAnnotations actual = emptyExpectedAnnotations(); + for (MetaDataItem item : items) + { + assertNotNull("Null item " + Arrays.asList(items), item); + Object object = item.getValue(); + assertNotNull("Null object " + Arrays.asList(items), object); + assertTrue("Not an annotation " + Arrays.asList(items), object instanceof Annotation); + Annotation annotation = (Annotation) object; + actual.add(annotation.annotationType()); + } + + assertExpectedAnnotations("AnnotationMetaDatas", expected, actual); + } + + /** * Assert two expected annotations * * @param context the context 1.2 +5 -1 container/src/tests/org/jboss/test/metadata/MetaDataAllTestSuite.java (In the diff below, changes in quantity of whitespace are not shown.) Index: MetaDataAllTestSuite.java =================================================================== RCS file: /cvsroot/jboss/container/src/tests/org/jboss/test/metadata/MetaDataAllTestSuite.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- MetaDataAllTestSuite.java 22 Jun 2006 14:57:30 -0000 1.1 +++ MetaDataAllTestSuite.java 10 Jul 2006 12:18:49 -0000 1.2 @@ -23,7 +23,9 @@ import org.jboss.test.metadata.context.MetaDataContextTestSuite; import org.jboss.test.metadata.loader.MetaDataLoaderTestSuite; +import org.jboss.test.metadata.repository.test.RepositoryTestSuite; import org.jboss.test.metadata.retrieval.test.RetrievalTestSuite; +import org.jboss.test.metadata.scope.test.ScopeTestSuite; import junit.framework.Test; import junit.framework.TestSuite; @@ -33,7 +35,7 @@ * MetaData All Test Suite. * * @author <a href="ad...@jb...">Adrian Brock</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class MetaDataAllTestSuite extends TestSuite { @@ -47,8 +49,10 @@ TestSuite suite = new TestSuite("MetaData Tests"); suite.addTest(RetrievalTestSuite.suite()); + suite.addTest(ScopeTestSuite.suite()); suite.addTest(MetaDataLoaderTestSuite.suite()); suite.addTest(MetaDataContextTestSuite.suite()); + suite.addTest(RepositoryTestSuite.suite()); return suite; } |