User: ejort Date: 02/02/17 04:41:52 Modified: src/main/javax/management QueryExp.java ValueExp.java Added: src/main/javax/management AttributeValueExp.java BinaryOpValueExp.java BooleanValueExp.java NumberValueExp.java Query.java QueryEval.java QueryExpSupport.java SingleValueExpSupport.java StringValueExp.java ValueExpSupport.java Log: Committed start of query support so I can do a full co Revision Changes Path 1.2 +49 -11 jmx/src/main/javax/management/QueryExp.java Index: QueryExp.java =================================================================== RCS file: /cvsroot/jboss/jmx/src/main/javax/management/QueryExp.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- QueryExp.java 3 Dec 2001 01:42:58 -0000 1.1 +++ QueryExp.java 17 Feb 2002 12:41:52 -0000 1.2 @@ -1,18 +1,56 @@ /* - * LGPL + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. */ package javax.management; -public interface QueryExp extends java.io.Serializable { +import java.io.Serializable; +/** + * A query expression.<p> + * + * An implementation of this interface can be used in + * a query. Multiple query expressions can be used together to form + * a more complex query. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. + * @version $Revision: 1.2 $ + */ +public interface QueryExp + extends Serializable +{ + // Constants --------------------------------------------------- + + // Public ------------------------------------------------------ + + /** + * Apply this query expression to an MBean. + * + * @param name the object name of the mbean + * @return true or false as the result of the query expression. + * @exception BadStringOperationException when an invalid string operation + * is used during query construction + * @exception BadBinaryOpValueExpException when an invalid binary operation + * is used during query construction + * @exception BadAttributeValueExpException when an invalid MBean attribute + * is used during query construction + * @exception InvalidApplicationException when trying to apply a subquery + * expression to an MBean or an attribute expression to an + * MBean of the wrong class. + */ public boolean apply(ObjectName name) - throws BadStringOperationException, - BadBinaryOpValueExpException, - BadAttributeValueExpException, - InvalidApplicationException; - - public void setMBeanServer(MBeanServer s); - - - + throws BadStringOperationException, + BadBinaryOpValueExpException, + BadAttributeValueExpException, + InvalidApplicationException; + + /** + * Set the MBeanServer for this query. Only MBeans registered in + * this server can be used in queries. + * + * @param server the MBeanServer + */ + public void setMBeanServer(MBeanServer server); } 1.2 +43 -7 jmx/src/main/javax/management/ValueExp.java Index: ValueExp.java =================================================================== RCS file: /cvsroot/jboss/jmx/src/main/javax/management/ValueExp.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ValueExp.java 3 Dec 2001 01:42:58 -0000 1.1 +++ ValueExp.java 17 Feb 2002 12:41:52 -0000 1.2 @@ -1,15 +1,51 @@ /* - * LGPL + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. */ package javax.management; -public interface ValueExp extends java.io.Serializable { +import java.io.Serializable; - public ValueExp apply(ObjectName name) - throws BadStringOperationException, - BadBinaryOpValueExpException, - BadAttributeValueExpException, - InvalidApplicationException; +/** + * A value expression.<p> + * + * Implementations of this interface represent arguments to expressions. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. + * @version $Revision: 1.2 $ + */ +public interface ValueExp + extends Serializable +{ + /** + * Apply this value expression to an MBean. + * + * @param name the object name of the mbean + * @return this value expression + * @exception BadStringOperationException when an invalid string operation + * is used during query construction + * @exception BadBinaryOpValueExpException when an invalid binary operation + * is used during query construction + * @exception BadAttributeValueExpException when an invalid MBean attribute + * is used during query construction + * @exception InvalidApplicationException when trying to apply a subquery + * expression to an MBean or an attribute expression to an + * MBean of the wrong class. + */ + public ValueExp apply(ObjectName name) + throws BadStringOperationException, + BadBinaryOpValueExpException, + BadAttributeValueExpException, + InvalidApplicationException; + /** + * Set the MBeanServer for this expression. Only MBeans registered in + * this server can be used in queries. + * + * @param server the MBeanServer + */ + public void setMBeanServer(MBeanServer server); } 1.1 jmx/src/main/javax/management/AttributeValueExp.java Index: AttributeValueExp.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; /** * A String that is an arguement to a query.<p> * * There is some duplication of implementation because of the poor * design. * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ public class AttributeValueExp implements ValueExp { // Constants --------------------------------------------------- // Attributes -------------------------------------------------- /** * The attribute name */ private String value; /** * The MBean server for this expression */ private MBeanServer server; // Static ----------------------------------------------------- // Constructors ------------------------------------------------ /** * Construct an attribute value expression for the null attribute name */ public AttributeValueExp() { } /** * Construct an attribute value expression for the passed attribute name * * @param value the attribute name */ public AttributeValueExp(String value) { this.value = value; } // Public ------------------------------------------------------ /** * Get the attribute name. * * @return the attribute name */ public String getAttributeName() { return value; } // ValueExp Implementation ------------------------------------- public ValueExp apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException { Object object = getAttribute(name); if (object instanceof String) return new StringValueExp((String) object); if (object instanceof Boolean) return new BooleanValueExp((Boolean) object); if (object instanceof Number) return new NumberValueExp((Number) object); //TODO boolean, int, long, float, double throw new BadAttributeValueExpException(object); } public void setMBeanServer(MBeanServer server) { this.server = server; } // Object overrides -------------------------------------------- public String toString() { return value; } // Protected --------------------------------------------------- /** * Get the value of the attribute for a given object name * * @param the object name * @return the value of the attribute */ protected Object getAttribute(ObjectName name) { try { return server.getAttribute(name, value); } catch (Exception e) { // TODO: What happens now? return null; } } // Package Private --------------------------------------------- // Private ----------------------------------------------------- // Inner Classes ----------------------------------------------- } 1.1 jmx/src/main/javax/management/BinaryOpValueExp.java Index: BinaryOpValueExp.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; /** * A Binary Operation that is an arguement to a query.<p> * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ /*package*/ class BinaryOpValueExp extends ValueExpSupport { // Constants --------------------------------------------------- // Attributes -------------------------------------------------- /** * The operation */ int operation; /** * The first expression */ ValueExp first; /** * The second expression */ ValueExp second; // Static ----------------------------------------------------- // Constructors ------------------------------------------------ /** * Construct a binary operation value * * @param operation the operation as defined in Query * @param first the first expression in the operation * @param second the second expression in the operation */ public BinaryOpValueExp(int operation, ValueExp first, ValueExp second) { this.operation = operation; this.first = first; this.second = second; } // Public ------------------------------------------------------ // X Implementation -------------------------------------------- // Y overrides ------------------------------------------------- // Protected --------------------------------------------------- // Package Private --------------------------------------------- // Private ----------------------------------------------------- // Inner Classes ----------------------------------------------- } 1.1 jmx/src/main/javax/management/BooleanValueExp.java Index: BooleanValueExp.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; /** * A Boolean that is an arguement to a query.<p> * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ /*package*/ class BooleanValueExp extends SingleValueExpSupport { // Constants --------------------------------------------------- // Attributes -------------------------------------------------- // Static ----------------------------------------------------- // Constructors ------------------------------------------------ /** * Construct a boolean value expression for the passed boolean * * @param value the boolean value */ public BooleanValueExp(Boolean value) { super(value); } // Public ------------------------------------------------------ // X Implementation -------------------------------------------- // Y overrides ------------------------------------------------- // Protected --------------------------------------------------- // Package Private --------------------------------------------- // Private ----------------------------------------------------- // Inner Classes ----------------------------------------------- } 1.1 jmx/src/main/javax/management/NumberValueExp.java Index: NumberValueExp.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; /** * A Number that is an arguement to a query.<p> * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ /*package*/ class NumberValueExp extends SingleValueExpSupport { // Constants --------------------------------------------------- // Attributes -------------------------------------------------- // Static ----------------------------------------------------- // Constructors ------------------------------------------------ /** * Construct a number value expression for the passed number * * @param value the value of number */ public NumberValueExp(Number value) { super(value); } // Public ------------------------------------------------------ // X Implementation -------------------------------------------- // Y overrides ------------------------------------------------- // Protected --------------------------------------------------- // Package Private --------------------------------------------- // Private ----------------------------------------------------- // Inner Classes ----------------------------------------------- } 1.1 jmx/src/main/javax/management/Query.java Index: Query.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; /** * This class is a factory for constructing queries.<p> * * TODO: Full explanation. See the spec for now for what it's worth. * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ public class Query { // Constants --------------------------------------------------- /** * Divide expression */ public static final int DIV = 1; /** * Equals expression */ public static final int EQ = 2; /** * Greater than or equals expression */ public static final int GE = 3; /** * Greater than expression */ public static final int GT = 4; /** * Less than or equals expression */ public static final int LE = 5; /** * Less than expression */ public static final int LT = 6; /** * Minus expression */ public static final int MINUS = 7; /** * Plus expression */ public static final int PLUS = 8; /** * Times expression */ public static final int TIMES = 9; // Attributes -------------------------------------------------- // Static ----------------------------------------------------- /** * An attribute expression * * @param value the name of the attribute * @return the expression */ public static ValueExp attr(String value) { return new AttributeValueExp(value); } /** * An expression that divides the first expression by the second * * @param first the first expression * @param second the second expression * @return the expression */ public static ValueExp div(ValueExp first, ValueExp second) { return new BinaryOpValueExp(DIV, first, second); } /** * An expression that subtracts the second expression from the first * * @param first the first expression * @param second the second expression * @return the expression */ public static ValueExp minus(ValueExp first, ValueExp second) { return new BinaryOpValueExp(MINUS, first, second); } /** * An expression that adds the second expression to the first * * @param first the first expression * @param second the second expression * @return the expression */ public static ValueExp plus(ValueExp first, ValueExp second) { return new BinaryOpValueExp(PLUS, first, second); } /** * An expression that multiplies the first expression by the second * * @param first the first expression * @param second the second expression * @return the expression */ public static ValueExp times(ValueExp first, ValueExp second) { return new BinaryOpValueExp(TIMES, first, second); } /** * Create a boolean value expression for use in a Query. * * @return the expression */ public static ValueExp value(boolean value) { return new BooleanValueExp(new Boolean(value)); } /** * Create a double value expression for use in a Query. * * @return the expression */ public static ValueExp value(double value) { return new NumberValueExp(new Double(value)); } /** * Create a float value expression for use in a Query. * * @return the expression */ public static ValueExp value(float value) { return new NumberValueExp(new Float(value)); } /** * Create an integer value expression for use in a Query. * * @return the expression */ public static ValueExp value(int value) { return new NumberValueExp(new Integer(value)); } /** * Create a long value expression for use in a Query. * * @return the expression */ public static ValueExp value(long value) { return new NumberValueExp(new Long(value)); } /** * Create a number value expression for use in a Query. * * @return the expression */ public static ValueExp value(Number value) { return new NumberValueExp(value); } /** * Create a string value expression for use in a Query. * * @return the expression */ public static ValueExp value(String value) { return new StringValueExp(value); } // Constructors ------------------------------------------------ /** * Construct a new Query */ public Query() { } // Public ------------------------------------------------------ // X Implementation -------------------------------------------- // Y overrides ------------------------------------------------- // Protected --------------------------------------------------- // Package Private --------------------------------------------- // Private ----------------------------------------------------- // Inner Classes ----------------------------------------------- } 1.1 jmx/src/main/javax/management/QueryEval.java Index: QueryEval.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; import java.io.Serializable; /** * Support for evaluting a query in the context of an MBeanServer.<p> * * This is obviously rubbish. Design and implementation shouldn't be * so closely bound together. * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ public abstract class QueryEval implements Serializable { // Constants --------------------------------------------------- // Attributes -------------------------------------------------- /** * I guess in the RI, all the implementation of queries is in * javax.management? */ /*package*/ MBeanServer server; // Public ------------------------------------------------------ /** * Set the MBeanServer for this query. Only MBeans registered in * this server can be used in queries. * * @param server the MBeanServer */ public void setMBeanServer(MBeanServer server) { this.server = server; } } 1.1 jmx/src/main/javax/management/QueryExpSupport.java Index: QueryExpSupport.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; import java.io.Serializable; /** * An implementation of Query expression. Apply always returns false. * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ /*package*/ class QueryExpSupport implements QueryExp { // Constants --------------------------------------------------- // Attributes -------------------------------------------------- /** * The MBean server */ protected MBeanServer server; // Static ------------------------------------------------------ // Public ------------------------------------------------------ // QueryExp implementation ------------------------------------- public boolean apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException { return false; } public void setMBeanServer(MBeanServer server) { this.server = server; } // X overides -------------------------------------------------- // Protected --------------------------------------------------- // Private ----------------------------------------------------- // Inner classes ----------------------------------------------- } 1.1 jmx/src/main/javax/management/SingleValueExpSupport.java Index: SingleValueExpSupport.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; import java.io.Serializable; /** * An implementation of single value expression. * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ /*package*/ class SingleValueExpSupport extends ValueExpSupport { // Constants --------------------------------------------------- // Attributes -------------------------------------------------- /** * The value of this object */ private Object value; // Static ------------------------------------------------------ // Constructor ------------------------------------------------- /** * Construct a value expression for the passed value * * @param value the value */ public SingleValueExpSupport(Object value) { this.value = value; } // Public ------------------------------------------------------ /** * Get the value of the expression */ public Object getValue() { return value; } // X implementation -------------------------------------------- // Object overrides -------------------------------------------- public String toString() { return value.toString(); } // Protected --------------------------------------------------- // Private ----------------------------------------------------- // Inner classes ----------------------------------------------- } 1.1 jmx/src/main/javax/management/StringValueExp.java Index: StringValueExp.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; /** * A String that is an arguement to a query.<p> * * There is some duplication of implementation because of the poor * design. * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ public class StringValueExp implements ValueExp { // Constants --------------------------------------------------- // Attributes -------------------------------------------------- /** * The value of the string */ private String value; /** * The MBean server for this expression */ private MBeanServer server; // Static ----------------------------------------------------- // Constructors ------------------------------------------------ /** * Construct a string value expression for the null string. */ public StringValueExp() { } /** * Construct a string value expression for the passed string * * @param value the string */ public StringValueExp(String value) { this.value = value; } // Public ------------------------------------------------------ /** * Get the value of the string. * * @return the string value */ public String getValue() { return value; } // ValueExp Implementation ------------------------------------- public ValueExp apply(ObjectName name) { return this; } public void setMBeanServer(MBeanServer server) { this.server = server; } // Object overrides -------------------------------------------- public String toString() { return value; } // Protected --------------------------------------------------- // Package Private --------------------------------------------- // Private ----------------------------------------------------- // Inner Classes ----------------------------------------------- } 1.1 jmx/src/main/javax/management/ValueExpSupport.java Index: ValueExpSupport.java =================================================================== /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ package javax.management; import java.io.Serializable; /** * An implementation of Value expression. Apply always returns this. * * @author <a href="mailto:[EMAIL PROTECTED]">Adrian Brock</a>. * @version $Revision: 1.1 $ */ /*package*/ class ValueExpSupport implements ValueExp { // Constants --------------------------------------------------- // Attributes -------------------------------------------------- /** * The MBean server */ private MBeanServer server; // Static ------------------------------------------------------ // Constructor ------------------------------------------------- // Public ------------------------------------------------------ /** * Get the MBean server */ public Object getMBeanServer() { return server; } // ValueExp implementation ------------------------------------- public ValueExp apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException { return this; } public void setMBeanServer(MBeanServer server) { this.server = server; } // Object overrides -------------------------------------------- // Protected --------------------------------------------------- // Private ----------------------------------------------------- // Inner classes ----------------------------------------------- }
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development