Author: james_r_bray
Date: Wed Nov 24 01:33:10 2010
New Revision: 1038425

URL: http://svn.apache.org/viewvc?rev=1038425&view=rev
Log: (empty)

Added:
    incubator/kitty/site/trunk/org/
    incubator/kitty/site/trunk/org/apache/
    incubator/kitty/site/trunk/org/apache/kitty/
    incubator/kitty/site/trunk/org/apache/kitty/Base.java
    incubator/kitty/site/trunk/org/apache/kitty/CmdShell.groovy
    incubator/kitty/site/trunk/org/apache/kitty/Main.groovy
    incubator/kitty/site/trunk/org/apache/kitty/client/
    incubator/kitty/site/trunk/org/apache/kitty/client/Client.groovy
    incubator/kitty/site/trunk/org/apache/kitty/client/jmxmp/
    incubator/kitty/site/trunk/org/apache/kitty/client/jmxmp/JMXMPClient.groovy
    incubator/kitty/site/trunk/org/apache/kitty/client/rmi/
    incubator/kitty/site/trunk/org/apache/kitty/client/rmi/RMIClient.groovy
    incubator/kitty/site/trunk/org/apache/kitty/exceptions/
    
incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainIsNoneException.groovy
    
incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainNotFoundException.groovy
    
incubator/kitty/site/trunk/org/apache/kitty/exceptions/InvokeException.groovy
    
incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanAttributeNotFoundException.groovy
    
incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanNotFoundException.groovy
    
incubator/kitty/site/trunk/org/apache/kitty/exceptions/OperationNotFoundException.groovy
    
incubator/kitty/site/trunk/org/apache/kitty/exceptions/SetAttributeException.groovy
    incubator/kitty/site/trunk/org/apache/kitty/test/
    incubator/kitty/site/trunk/org/apache/kitty/test/ClientTest0.groovy
    incubator/kitty/site/trunk/org/apache/kitty/test/Test.java
    incubator/kitty/site/trunk/org/apache/kitty/test/TestGroovyShell.groovy
    incubator/kitty/site/trunk/org/apache/kitty/test/TestShell.java
    incubator/kitty/site/trunk/org/apache/kitty/ui/
    incubator/kitty/site/trunk/org/apache/kitty/ui/Console.groovy
    incubator/kitty/site/trunk/org/apache/kitty/ui/Dashboard.groovy
    incubator/kitty/site/trunk/org/apache/kitty/utils/
    incubator/kitty/site/trunk/org/apache/kitty/utils/Constants.java
    incubator/kitty/site/trunk/org/apache/kitty/utils/Help.groovy

Added: incubator/kitty/site/trunk/org/apache/kitty/Base.java
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/Base.java?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/Base.java (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/Base.java Wed Nov 24 01:33:10 
2010
@@ -0,0 +1,5 @@
+package org.apache.kitty;
+
+public interface Base {
+
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/CmdShell.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/CmdShell.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/CmdShell.groovy (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/CmdShell.groovy Wed Nov 24 
01:33:10 2010
@@ -0,0 +1,400 @@
+/**
+ * 
+ */
+package org.apache.kitty
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import org.apache.kitty.client.Client;
+import org.apache.kitty.utils.Help;
+import org.apache.kitty.utils.Constants;
+
+/**
+ * <pre>
+ * <b>Description</b>
+ * <p>
+ * This is a command shell class that is used for a command line user 
interface for the management console
+ * </p>
+ * </pre>
+ * @author James R. Bray, Jr.
+ *
+ */
+class CmdShell {
+       
+       def static final PROMPT = "kitty>"
+       static String HOST = "localhost"
+       static String PORT = "9024"
+       static Client client
+       def static remote
+       static InputStreamReader inReader;
+       static BufferedReader bReader;
+       static commands = ["help", "connect", "disconnect", "exit", "ls", 
"echo", "domains", "cd", "get", "set", "invoke", "pwd", "setdomain"]
+
+       /**
+        * 
+        */
+       public CmdShell() {
+               // TODO Auto-generated constructor stub
+       }
+
+
+       static main(args) {
+               startShell()
+       }
+       
+       static startShell()
+       {
+               def input
+               this.inReader = new InputStreamReader(System.in)
+               this.bReader = new BufferedReader(inReader)
+               this.client = new Client()
+               
+               while(!(input.equals("exit")))
+               {
+                       print PROMPT
+                       input = getUserInput()
+                       inputHandler(input)
+               }
+               this.inReader.close()
+               this.bReader.close()
+               
+       }
+       
+       static inputHandler(String input)
+       {
+               Integer index = 0
+               String[] params
+               
+               if(input.contains(" "))
+               {
+                       params = input.split(" ")
+                       input = params[0]
+               }
+               else
+               {
+                       params = {input}
+               }
+               
+               if(this.commands.contains(input))
+               {
+                       index = commands.indexOf(input)
+                       //println "The index is" + index
+                       
+                       switch(index)
+                       {
+                               case 0:
+                                       cmdHelp()
+                                       break;
+                               case 1:
+                                       if(params.length > 3)
+                                       {
+                                               println "You have entered an 
invalid number of parameters, you may enter host and port as parameters only"
+                                       }
+                                       if(params.length == 3)
+                                       {
+                                               cmdConnect(params[1],params[2])
+                                       }
+                                       else
+                                       {
+                                               if(params.length == 2)
+                                               {
+                                                       cmdConnect(params[1])
+                                               }
+                                               else
+                                               {
+                                                       cmdConnect()
+                                               }
+                                       }
+                                       break;
+                               case 2:
+                                       cmdDisconnect()
+                                       this.remote = null;
+                                       break;
+                               case 3:
+                                       cmdExit()
+                                       break;
+                               case 4:
+                                       cmdLs()
+                                       break;
+                               case 5:
+                                       cmdEcho(params)
+                                       break;
+                               case 6:
+                                       cmdDomains()
+                                       break;
+                               case 7:
+                                       if(params.length >= 2)
+                                       {
+                                               cmdCd(params[1])
+                                       }
+                                       else
+                                       {
+                                               println 
Constants.ERROR_TOO_FEW_PARAMETERS
+                                               println "You must enter a path 
parameter after 'cd'"
+                                       }
+                                       break;
+                               case 8:
+                                       if(params.length >= 2)
+                                       {
+                                               cmdGet(params[1])
+                                       }
+                                       else
+                                       {
+                                               println 
Constants.ERROR_TOO_FEW_PARAMETERS
+                                               println "You must enter at 1 
parameter after the command"
+                                       }
+                                       break;
+                               case 9:
+                                       if(params.length >= 3)
+                                       {
+                                               cmdSet(params[1], params[2])
+                                       }
+                                       else
+                                       {
+                                               println 
Constants.ERROR_TOO_FEW_PARAMETERS
+                                               println "You must enter an 
attribute parameter and a value parameter"
+                                       }
+                                       break;
+                               case 10:
+                                       if(params.length >= 3)
+                                       {
+                                               cmdInvoke(params[1],params[2])
+                                       }
+                                       else
+                                       {
+                                               println 
Constants.ERROR_TOO_FEW_PARAMETERS
+                                               println "You must enter an 
operation name followed by parameter(s)"
+                                       }
+                                               
+                                       break;
+                               case 11:
+                                       cmdPwd()
+                                       break;
+                               case 12:
+                                       if(params.length >= 2)
+                                       {
+                                               cmdSetDomain(params[1])
+                                       }
+                                       else
+                                       {
+                                               println 
Constants.ERROR_TOO_FEW_PARAMETERS
+                                               println "You must enter a 
domain name parameter after 'setdomain' command"
+                                       }
+                                       break;
+                               default:
+                                       break;
+                       }
+               }
+               else
+               {
+                       println input + " is not a valid command"
+               }
+       }
+       
+       static String getUserInput()
+       {
+               def userInput
+               userInput = bReader.readLine()
+               return userInput;
+       }
+       
+       static cmdHelp()
+       {
+               Help h = new Help()
+               println h.toString()
+       }
+       
+       static cmdConnect()
+       {
+               def _host = this.HOST
+               def _port = this.PORT
+               println "connecting to $_host at port $_port...."
+               this.getClient().connect(this.HOST, this.PORT)
+               if(this.getClient().getRemote())
+               {
+                       println "Successfully connected to host"
+                       this.remote = this.getClient().getRemote()
+               }
+               else
+               {
+                       println "Connection attempt was unsuccessful"
+               }
+               
+       }
+       
+       static cmdConnect(_host)
+       {
+               def _port = this.PORT
+               this.getClient().connect(_host, this.PORT)
+               println "connecting to $_host at port $_port...."
+               if(this.getClient().getRemote())
+               {
+                       println "Successfully connected to host"
+                       this.remote = this.getClient().getRemote()
+               }
+               else
+               {
+                       println "Connection attempt was unsuccessful"
+               }
+               
+       }
+       
+       static cmdConnect(_host, _port)
+       {
+               println "connecting to $_host at port $_port...."
+               this.getClient().connect(_host, _port)
+               if(this.getClient().getRemote())
+               {
+                       println "Successfully connected to host"
+                       this.remote = this.getClient().getRemote()
+               }
+               else
+               {
+                       println "Connection attempt was unsuccessful"
+               }
+               
+       }
+       
+       static cmdDisconnect()
+       {
+               println "disconnecting..."
+               if(client.getRemote())
+               {
+                       this.client.disconnect();
+                       if(!client.getRemote())
+                       {
+                               println "successfully disconnected from host"
+                       }
+               }
+               else
+               {
+                       println "client can not disconnect because it is not 
connected to a host"
+               }
+               
+       }
+       
+       static cmdExit()
+       {
+               println "exiting..."
+               println "successfully exited kitty"
+       }
+       
+       static cmdLs()
+       {
+               println "listing files and directories..."
+               if(remote)
+               {
+                       this.getClient().ls()
+                       println "The domain list is:"
+               }
+               else
+               {
+                       println Constants.ERROR_NOT_CONNECTED
+               }
+       }
+       
+       static cmdEcho(def input)
+       {
+               if(input.size() > 1)
+               {
+                       input.each { print it+" " }
+               }
+               println()
+       }
+       
+       static cmdDomains()
+       {
+               println "getting domains..."
+               def domains = this.getClient().getDomainList()
+               if(domains)
+               {
+                       println "A list of domains is available"
+               }
+               else
+               {
+                       println "No domains are available"
+               }
+       }
+       
+       static cmdCd(String path)
+       {
+               println "changing remote path..."
+               if(remote)
+               {
+                       this.getClient().cd(path)
+               }
+               else
+               {
+                       println Constants.ERROR_NOT_CONNECTED
+               }
+       }
+       
+       static cmdGet(def attr)
+       {
+               println "get $attr..."
+               if(remote)
+               {
+                       this.getClient().get(attr)
+               }
+               else
+               {
+                       println Constants.ERROR_NOT_CONNECTED
+               }
+       }
+       
+       static cmdSet(def attr, def val)
+       {
+               println "set $attr to $val"
+               if(remote)
+               {
+                       this.getClient().set(attr, val)
+               }
+               else
+               {
+                       println Constants.ERROR_NOT_CONNECTED
+               }
+       }
+       
+       static cmdInvoke(def op, def params)
+       {
+               println "Invoking the following operation: $op"
+               if(remote)
+               {
+                       this.getClient().invoke(op, params)
+               }
+               else
+               {
+                       println Constants.ERROR_NOT_CONNECTED
+               }
+       }
+       
+       static cmdPwd()
+       {
+               println "Displaying the current remote path..."
+               if(remote)
+               {
+                       String name = (String)this.getClient().pwd()
+                       println name
+               }
+               else
+               {
+                       println Constants.ERROR_NOT_CONNECTED
+               }
+       }
+       
+       static cmdSetDomain(def domain)
+       {
+               println "Setting the domain to $domain..."
+               if(remote)
+               {
+                       this.getClient().setDomain(domain)
+                       println "The domain is set to $domain"
+               }
+               else
+               {
+                       println Constants.ERROR_NOT_CONNECTED
+               }
+       }
+       
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/Main.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/Main.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/Main.groovy (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/Main.groovy Wed Nov 24 01:33:10 
2010
@@ -0,0 +1,24 @@
+package org.apache.kitty
+
+/**
+* <pre>
+* <b>Description</b>
+* <p>
+* This is the entry point to the remote management framework.
+* </p>
+* </pre>
+*
+* @author James R. Bray, Jr.
+*
+*/
+class Main {
+       
+       def config
+       
+       public init()
+       {
+               config = new ConfigSlurper().parse(new 
File('kittyConfig.groovy')).toString()
+               //TODO
+       }
+
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/client/Client.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/client/Client.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/client/Client.groovy (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/client/Client.groovy Wed Nov 24 
01:33:10 2010
@@ -0,0 +1,462 @@
+package org.apache.kitty.client
+
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+import javax.management.ObjectName;
+import javax.management.Attribute;
+import org.apache.kitty.exceptions.*;
+
+
+/**
+ * <pre>
+ * <b>Description</p>
+ * <p>
+ * This is a Groovy implementation of the JSR 160 for a remote client.
+ * It is generic and will be the basis for the rmi and jmxmp implemenentations 
of the client.
+ * This class is for development purposes only and will not be used in 
production.
+ * </p>
+ * </pre>
+ * 
+ * @author James R. Bray, Jr.
+ * @version 1.0
+ *
+ */
+class Client {
+       
+       def host
+       def port
+       def domain
+       def domainList
+       def mBeansPath
+       def remote
+       def connector
+       def url
+       
+       public connect(def _host, def _port)
+       {
+               //TODO
+               def serviceURL
+               if(remote != null)
+               {
+                       disconnect()
+               }
+               
+               try
+               {
+                       serviceURL = 
"service:jmx:rmi:///jndi/rmi://$_host:$_port/jmxrmi"
+                       this.url = new JMXServiceURL(serviceURL)
+                       println "the url is $url"
+                       this.connector = JMXConnectorFactory.connect(this.url)
+                       this.remote = this.connector.getMBeanServerConnection()
+               }
+               catch(IOException e)
+               {
+                       connector = null
+                       remote = null
+                       println e.getMessage()
+               }
+               finally
+               {
+                       if(this.remote != null)
+                       {
+                               this.host = _host
+                               this.port = _port
+                       }
+               }
+       }
+       
+       public disconnect()
+       {
+               try
+               {
+                       if(this.remote != null)
+                       {
+                               connector.close()
+                       }
+               }
+               finally
+               {
+                       this.host = null
+                       this.port = null
+                       this.remote = null
+                       this.connector = null
+                       this.domain = null
+                       this.mBeansPath = null
+               }
+       }
+       
+       /**
+        * <pre>
+        * Get a list of domains from the remote host and print the list to 
standard output
+        * </pre>
+        * @return
+        */
+       public domains()
+       {
+               if(this.remote)
+               {
+                       this.domainList = remote.getDomains()
+                       this.domainList.each { println it }
+               }
+               else
+               {
+                       println "The remote connection is null"
+               }
+       }
+       
+       /**
+        * <pre>
+        * Assign a value to the domain
+        * </pre>
+        * @param _domain
+        * @return
+        */
+       public setDomain(def _domain)
+       {
+               if(this.remote)
+               {
+                       if(_domain.equals(""))
+                       {
+                               this.domain = null
+                               return
+                       }
+                       
+                       this.domainList = remote.getDomains()
+                       this.domainList.each {
+                               if(it.equals(_domain))
+                               {
+                                       this.domain = _domain
+                                       this.mBeanPath = []
+                                       return
+                               }
+                       }
+               }
+               else
+               {
+                       println "domain not found"
+               }
+       }
+       
+       /**
+        * 
+        * @return
+        */
+       public ls()
+       {
+               if(this.remote)
+               {
+                       if(this.domain)
+                       {
+                               def objectName = this.domain + ":"
+                               def objectName2
+                               if(objectName.length() > 0)
+                               {
+                                       objectName += 
",".concat(this.mBeansPath.join())  // make sure mBeansPath is a list, 
otherwise remove the .join() command
+                                       objectName2 = objectName + ","
+                               }
+                               else
+                               {
+                                       objectName2 = objectName
+                               }
+                               def pool = new ObjectName(objectName2 + "*")
+                               def paths = {}
+                               println objectName
+                               println "-----"
+                               def qNames = this.remote.queryNames(pool, null)
+                               try
+                               {
+                                       qNames.each { mbean ->
+                                               def p = 
mbean.toString().split(objectName2)[1].split(',')[0]
+                                               paths[p] = p
+                                       }
+                                       paths.each { p -> 
+                                               println  "M " + p
+                                       }
+                               }
+                               catch(Exception e)
+                               {
+                                       throw new DomainIsNoneException()
+                               }
+                               
+                               try
+                               {
+                                       mbean = this.remote.getMBeanInfo( new 
ObjectName(objectName))
+                                       for(attr in mbean.getAttributes())
+                                       {
+                                               def readable
+                                               def writable
+                                               try
+                                               {
+                                                       def value = 
this.remote.getAttribute(new ObjectName(objectName), attr.getName())
+                                                       def valueStr = 
(String)value
+                                               }
+                                               catch(Exception e)
+                                               {
+                                                       valueStr = "-- " + 
attr.getType() + " --"
+                                               }
+                                               if(attr.isReadable())
+                                               {
+                                                       readable = "r"
+                                               }
+                                               else
+                                               {
+                                                       readable = "-"
+                                               }
+                                               if(attr.isWritable())
+                                               {
+                                                       writable = "w"
+                                               }
+                                               else
+                                               {
+                                                       writable = "-"
+                                               }
+                                               println "A " + readable + 
writable + " " + attr.getName() + " : "  + valueStr
+                                       }
+                               }
+                               catch(Exception e)
+                               {
+                                       //
+                               }
+                               
+                               try
+                               {
+                                       mbean = this.remote.getMBeanInfo( new 
ObjectName(objectName))
+                                       for(ops in mbean.getOperations())
+                                       {
+                                               def params = []
+                                               for(p in ops.getSignature())
+                                               {
+                                                       
params.append(p.getType())
+                                               }
+                                               println "O " + 
ops.getReturnType()  + " " + ops.getName() + " ( "  + ",".concat(params.join()) 
+  ")"
+                                       }
+                               }
+                               catch(Exception e)
+                               {
+                                       throw new DomainIsNoneException()
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * 
+        * @return
+        */
+       public cd(String path)
+       {
+               if(this.remote)
+               {
+                       if(this.domain)
+                       {
+                if(path == "..")
+                               {
+                    if(this.mBeansPath.length())
+                                       {
+                        this.mBeansPath.pop()
+                                       }
+                               }
+                else
+                               {
+                    for(p in path.split(','))
+                                       {
+                        this.mBeansPath.append(p)
+                                       }
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * 
+        */
+       public get(att)
+       {
+               if(this.remote)
+               {
+                       if(this.domain)
+                       {
+                def objectName = this.domain + ":"
+                               def readable
+                               def writable
+                               def valueStr  
+                if(this.mBeansPath.length > 0)
+                               {
+                    objectName = objectName + 
','.concat(this.mBeansPath.join())
+                               }
+                try
+                               {
+                    mbean = this.remote.getMBeanInfo(new 
ObjectName(objectName))
+                               }
+                catch(Exception e)
+                               {
+                    throw new MBeanNotFoundException()
+                               }
+                attr = null 
+                for(a in mbean.getAttributes())
+                               {
+                    if(a.getName()  == att)
+                                       {
+                        attr = a 
+                        break
+                                       }
+                               }
+                if(!attr)
+                               {
+                    throw new MBeanAttributeNotFoundException()     
+                               }              
+                try
+                               {
+                    value = this.remote.getAttribute(new 
ObjectName(objectName), att) 
+                    valueStr = str(value)
+                               }
+                catch(Exception e)
+                               {
+                    valueStr = "-- " + attr.getType() + " --" 
+                               }
+                if(attr.isReadable())
+                               {
+                    readable = "Y"
+                               }
+                else
+                               {
+                    readable = "N"
+                               }
+                if(attr.isWritable())
+                               {
+                    writable = "Y" 
+                               }
+                else
+                               {
+                    writable = "N" 
+                               }
+                println "ObjectName :" + objectName
+                println "Attribute  :" + attr.getName()
+                println "Value      :"  + valueStr
+                println "isReadable : " + readable 
+                println "isWritable : " + writable 
+                       }
+               }
+       }
+       
+       /**
+        * 
+        * @return
+        */
+       public set(att, val)
+       {
+               if(this.remote)
+               {
+                       if(this.domain)
+                       {
+                def objectName = this.domain + ":"         
+                if(this.mBeansPath.length() > 0)
+                               {
+                    objectName = objectName + 
','.concat(this.mBeansPath.join())
+                               }
+                try
+                               {
+                    mbean = this.remote.getMBeanInfo(new 
ObjectName(objectName))
+                               }
+                catch(Exception e)
+                               {
+                    throw new MBeanNotFoundException()
+                               }
+                attr = null 
+                for(a in mbean.getAttributes())
+                               {
+                    if(a.getName()  == att)
+                        attr = a 
+                        break
+                               }
+                if(!attr)
+                               {
+                    throw new MBeanAttributeNotFoundException()
+                               }
+                if(attr.isWritable())
+                               {
+                    try
+                                       {
+                        a = new Attribute(att, val)
+                        this.remote.setAttribute(new ObjectName(objectName), a)
+                                       }
+                    catch(Exception e)
+                                       {
+                        throw new SetAttributeException()
+                                       }
+                               }
+                else
+                               {
+                    throw new SetAttributeException()
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * 
+        * @param op
+        * @param params
+        * @return
+        */
+       public invoke(op, params)
+       {
+               if(this.remote)
+               {
+                       if(this.domain)
+                       {
+                               def objectName = this.domain + ":"
+                               if(this.mBeansPath.length())
+                               {
+                                       objectName = objectName + 
','.concat(this.mBeansPath.join())
+                               }
+                               try{
+                                       mbean = this.remote.getMBeanInfo(new 
ObjectName(objectName))
+                               }
+                               catch(Exception)
+                               {
+                                       throw new MBeanNotFoundException()
+                               }
+                               def ops = null
+                               for(o in mbean.getOperations())
+                               {
+                                       if(o.getName() == op)
+                                       {
+                                               ops = o
+                                               break
+                                       }
+                               }
+                               if(!ops)
+                               {
+                                       throw new OperationNotFoundException()
+                               }
+                               def sig = []
+                               for(s in ops.getSignature())
+                               {
+                                       sig.append(p.getType())
+                               }
+       
+                               try
+                               {
+                                       this.remote.invoke(new 
ObjectName(objectName), op, params, sig)
+                               }
+                               catch(Exception e)
+                               {
+                                       throw new InvokeException()
+                               }
+                       }
+               }
+       }
+       
+       public pwd()
+       {
+               def name
+               if(this.domain)
+               {
+                       name = this.domain + ":" + 
",".concat(this.mBeansPath.join())  // may need to change this
+               }
+               
+               return name
+       }
+
+}

Added: 
incubator/kitty/site/trunk/org/apache/kitty/client/jmxmp/JMXMPClient.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/client/jmxmp/JMXMPClient.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/client/jmxmp/JMXMPClient.groovy 
(added)
+++ incubator/kitty/site/trunk/org/apache/kitty/client/jmxmp/JMXMPClient.groovy 
Wed Nov 24 01:33:10 2010
@@ -0,0 +1,59 @@
+/**
+ * 
+ */
+package org.apache.kitty.client.jmxmp
+
+import org.apache.kitty.client.Client;
+
+/**
+ * <pre>
+ * <b>Description</b>
+ * <p>
+ * 
+ * </p>
+ * </pre>
+ * @author James R. Bray, Jr.
+ *
+ */
+class JMXMPClient extends Client {
+       
+       def host
+       def port
+       def domain
+       def mBeansPath
+       def remote
+       def connector
+       
+       @Override
+       public connect(def _host, def _port)
+       {
+               //TODO
+               def serviceURL
+               if(remote != null)
+               {
+                       disconnect()
+               }
+               
+               try
+               {
+                       serviceURL = "service:jmx:jmxmp://$_host:$_port"
+                       this.url = JMXServiceURL(serviceURL)
+                       this.connector = JMXConnectorFactory.connect(url)
+                       this.remote = this.connector.getMBeanServerConnection()
+               }
+               catch(IOException e)
+               {
+                       connector = null
+                       remote = null
+               }
+               finally
+               {
+                       if(this.remote != null)
+                       {
+                               this.host = _host
+                               this.port = _port
+                       }
+               }
+       }
+
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/client/rmi/RMIClient.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/client/rmi/RMIClient.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/client/rmi/RMIClient.groovy 
(added)
+++ incubator/kitty/site/trunk/org/apache/kitty/client/rmi/RMIClient.groovy Wed 
Nov 24 01:33:10 2010
@@ -0,0 +1,14 @@
+package org.apache.kitty.client.rmi
+
+import org.apache.kitty.client.Client;
+
+class RMIClient extends Client {
+       
+       def host
+       def port
+       def domain
+       def mBeansPath
+       def remote
+       def connector
+
+}

Added: 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainIsNoneException.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainIsNoneException.groovy?rev=1038425&view=auto
==============================================================================
--- 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainIsNoneException.groovy
 (added)
+++ 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainIsNoneException.groovy
 Wed Nov 24 01:33:10 2010
@@ -0,0 +1,12 @@
+/**
+ * 
+ */
+package org.apache.kitty.exceptions
+
+/**
+ * @author james
+ *
+ */
+class DomainIsNoneException extends Exception {
+
+}

Added: 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainNotFoundException.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainNotFoundException.groovy?rev=1038425&view=auto
==============================================================================
--- 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainNotFoundException.groovy
 (added)
+++ 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/DomainNotFoundException.groovy
 Wed Nov 24 01:33:10 2010
@@ -0,0 +1,5 @@
+package org.apache.kitty.exceptions
+
+class DomainNotFoundException extends Exception {
+
+}

Added: 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/InvokeException.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/exceptions/InvokeException.groovy?rev=1038425&view=auto
==============================================================================
--- 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/InvokeException.groovy 
(added)
+++ 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/InvokeException.groovy 
Wed Nov 24 01:33:10 2010
@@ -0,0 +1,44 @@
+/**
+ * 
+ */
+package org.apache.kitty.exceptions
+
+/**
+ * @author james
+ *
+ */
+class InvokeException extends Exception {
+
+       /**
+        * 
+        */
+       public InvokeException() {
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        */
+       public InvokeException(String message) {
+               super(message);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param cause
+        */
+       public InvokeException(Throwable cause) {
+               super(cause);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        * @param cause
+        */
+       public InvokeException(String message, Throwable cause) {
+               super(message, cause);
+               // TODO Auto-generated constructor stub
+       }
+
+}

Added: 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanAttributeNotFoundException.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanAttributeNotFoundException.groovy?rev=1038425&view=auto
==============================================================================
--- 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanAttributeNotFoundException.groovy
 (added)
+++ 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanAttributeNotFoundException.groovy
 Wed Nov 24 01:33:10 2010
@@ -0,0 +1,44 @@
+/**
+ * 
+ */
+package org.apache.kitty.exceptions
+
+/**
+ * @author james
+ *
+ */
+class MBeanAttributeNotFoundException extends Exception {
+
+       /**
+        * 
+        */
+       public MBeanAttributeNotFoundException() {
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        */
+       public MBeanAttributeNotFoundException(String message) {
+               super(message);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param cause
+        */
+       public MBeanAttributeNotFoundException(Throwable cause) {
+               super(cause);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        * @param cause
+        */
+       public MBeanAttributeNotFoundException(String message, Throwable cause) 
{
+               super(message, cause);
+               // TODO Auto-generated constructor stub
+       }
+
+}

Added: 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanNotFoundException.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanNotFoundException.groovy?rev=1038425&view=auto
==============================================================================
--- 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanNotFoundException.groovy
 (added)
+++ 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/MBeanNotFoundException.groovy
 Wed Nov 24 01:33:10 2010
@@ -0,0 +1,44 @@
+/**
+ * 
+ */
+package org.apache.kitty.exceptions
+
+/**
+ * @author james
+ *
+ */
+class MBeanNotFoundException extends Exception {
+
+       /**
+        * 
+        */
+       public MBeanNotFoundException() {
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        */
+       public MBeanNotFoundException(String message) {
+               super(message);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param cause
+        */
+       public MBeanNotFoundException(Throwable cause) {
+               super(cause);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        * @param cause
+        */
+       public MBeanNotFoundException(String message, Throwable cause) {
+               super(message, cause);
+               // TODO Auto-generated constructor stub
+       }
+
+}

Added: 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/OperationNotFoundException.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/exceptions/OperationNotFoundException.groovy?rev=1038425&view=auto
==============================================================================
--- 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/OperationNotFoundException.groovy
 (added)
+++ 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/OperationNotFoundException.groovy
 Wed Nov 24 01:33:10 2010
@@ -0,0 +1,5 @@
+package org.apache.kitty.exceptions
+
+class OperationNotFoundException extends Exception {
+
+}

Added: 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/SetAttributeException.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/exceptions/SetAttributeException.groovy?rev=1038425&view=auto
==============================================================================
--- 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/SetAttributeException.groovy
 (added)
+++ 
incubator/kitty/site/trunk/org/apache/kitty/exceptions/SetAttributeException.groovy
 Wed Nov 24 01:33:10 2010
@@ -0,0 +1,44 @@
+/**
+ * 
+ */
+package org.apache.kitty.exceptions
+
+/**
+ * @author james
+ *
+ */
+class SetAttributeException extends Exception {
+
+       /**
+        * 
+        */
+       public SetAttributeException() {
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        */
+       public SetAttributeException(String message) {
+               super(message);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param cause
+        */
+       public SetAttributeException(Throwable cause) {
+               super(cause);
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param message
+        * @param cause
+        */
+       public SetAttributeException(String message, Throwable cause) {
+               super(message, cause);
+               // TODO Auto-generated constructor stub
+       }
+
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/test/ClientTest0.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/test/ClientTest0.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/test/ClientTest0.groovy (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/test/ClientTest0.groovy Wed Nov 
24 01:33:10 2010
@@ -0,0 +1,41 @@
+/**
+ * 
+ */
+package org.apache.kitty.test;
+
+import groovy.util.GroovyTestCase;
+
+/**
+ * @author james
+ *
+ */
+class ClientTest extends GroovyTestCase {
+
+       /**
+        * @param name
+        */
+       public ClientTest(String name) {
+               super(name);
+       }
+
+       /* (non-Javadoc)
+        * @see junit.framework.TestCase#setUp()
+        */
+       protected void setUp() throws Exception {
+               super.setUp();
+       }
+
+       /* (non-Javadoc)
+        * @see junit.framework.TestCase#tearDown()
+        */
+       protected void tearDown() throws Exception {
+               super.tearDown();
+       }
+}
+
+       /**
+        * Test method for {...@link 
org.apache.kitty.client.Client#connect(java.lang.Object, java.lang.Object)}.
+        */
+       public final void testConnect(){
+       fail("Not yet implemented"); // TODO
+       }

Added: incubator/kitty/site/trunk/org/apache/kitty/test/Test.java
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/test/Test.java?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/test/Test.java (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/test/Test.java Wed Nov 24 
01:33:10 2010
@@ -0,0 +1,23 @@
+package org.apache.kitty.test;
+
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+import javax.management.ObjectName;
+import javax.management.MBeanInfo;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import java.lang.management.ManagementFactory;
+import javax.management.AttributeNotFoundException;
+
+/**
+ * <pre>
+ * Test some simple concepts and assumptions here
+ * </pre>
+ * @author james
+ *
+ */
+public class Test {
+
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/test/TestGroovyShell.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/test/TestGroovyShell.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/test/TestGroovyShell.groovy 
(added)
+++ incubator/kitty/site/trunk/org/apache/kitty/test/TestGroovyShell.groovy Wed 
Nov 24 01:33:10 2010
@@ -0,0 +1,132 @@
+/**
+ * 
+ */
+package org.apache.kitty.test
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import org.apache.kitty.utils.Help;
+
+/**
+ * @author James R. Bray, Jr.
+ *
+ */
+class TestGroovyShell {
+       
+       def static final PROMPT = "kitty>"
+       static InputStreamReader inReader;
+       static BufferedReader bReader;
+       static commands = ["help", "connect", "disconnect", "exit", "ls", 
"echo"]
+
+       /**
+        * 
+        */
+       public TestGroovyShell() {
+               // TODO Auto-generated constructor stub
+       }
+
+
+       static main(args) {
+               startShell()
+       }
+       
+       static startShell()
+       {
+               def input
+               this.inReader = new InputStreamReader(System.in)
+               this.bReader = new BufferedReader(inReader)
+               
+               while(!(input.equals("exit")))
+               {
+                       print PROMPT
+                       input = getUserInput()
+                       inputHandler(input)
+               }
+               this.inReader.close()
+               this.bReader.close()
+               
+       }
+       
+       static inputHandler(String input)
+       {
+               //print input
+               
+               Integer index = 0
+               
+               if(this.commands.contains(input))
+               {
+                       index = commands.indexOf(input)
+                       //println "The index is" + index
+                       
+                       switch(index)
+                       {
+                               case 0:
+                                       cmdHelp()
+                                       break;
+                               case 1:
+                                       cmdConnect()
+                                       break;
+                               case 2:
+                                       cmdDisconnect()
+                                       break;
+                               case 3:
+                                       cmdExit()
+                                       break;
+                               case 4:
+                                       cmdLs()
+                                       break;
+                               case 5:
+                                       cmdEcho(input)
+                                       break;
+                               default:
+                                       break;
+                       }
+               }
+               else
+               {
+                       println input + " is not a valid command"
+               }
+               
+               
+       }
+       
+       static String getUserInput()
+       {
+               def userInput
+               userInput = bReader.readLine()
+               return userInput;
+       }
+       
+       static cmdHelp()
+       {
+               Help h = new Help()
+               println h.toString()
+       }
+       
+       static cmdConnect()
+       {
+               println "connecting...."
+       }
+       
+       static cmdDisconnect()
+       {
+               println "disconnecting..."
+       }
+       
+       static cmdExit()
+       {
+               println "exiting..."
+       }
+       
+       static cmdLs()
+       {
+               println "listing files and directories..."
+       }
+       
+       static cmdEcho(def input)
+       {
+               println input
+       }
+       
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/test/TestShell.java
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/test/TestShell.java?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/test/TestShell.java (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/test/TestShell.java Wed Nov 24 
01:33:10 2010
@@ -0,0 +1,90 @@
+/**
+ * 
+ */
+package org.apache.kitty.test;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * @author james
+ *
+ */
+public class TestShell {
+       
+       protected static final String PROMPT = "kitty>";
+       static InputStreamReader inReader;
+       static BufferedReader bReader;
+
+       /**
+        * 
+        */
+       public TestShell() {
+               // TODO Auto-generated constructor stub
+       }
+
+       /**
+        * @param args
+        */
+       public static void main(String[] args) {
+               startShell();
+
+       }
+       
+       public static void startShell()
+       {
+               String input = "";
+               inReader = new InputStreamReader(System.in);
+               bReader = new BufferedReader(inReader);
+               while(!(input.equals("exit")))
+               {
+                       getPrompt();
+                       input = getUserInput();
+                       validateInput(input);
+                       processInput(input);
+               }
+               
+               try
+               {
+                       inReader.close();
+                       bReader.close();
+               }
+               catch(IOException ioe)
+               {
+                       System.err.println(ioe.getMessage());
+               }
+               System.out.println("kitty session terminated");
+       }
+       
+       public static void getPrompt()
+       {
+               System.out.print(PROMPT);
+       }
+       
+       public static String getUserInput()
+       {
+               String userInput = null;
+               try
+               {
+                       userInput = bReader.readLine();
+               }
+               catch(IOException ioe)
+               {
+                       System.err.println(ioe.getMessage());
+               }
+               
+               return userInput;
+       }
+       
+       private static void validateInput(String input)
+       {
+               //TODO
+       }
+       
+       private static void processInput(String input)
+       {
+               //TODO
+       }
+
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/ui/Console.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/ui/Console.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/ui/Console.groovy (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/ui/Console.groovy Wed Nov 24 
01:33:10 2010
@@ -0,0 +1,19 @@
+/**
+ * 
+ */
+package org.apache.kitty.ui
+
+/**
+ * @author james
+ *
+ */
+class Console {
+
+       /**
+        * 
+        */
+       public Console() {
+               // TODO Auto-generated constructor stub
+       }
+
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/ui/Dashboard.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/ui/Dashboard.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/ui/Dashboard.groovy (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/ui/Dashboard.groovy Wed Nov 24 
01:33:10 2010
@@ -0,0 +1,28 @@
+/**
+ * 
+ */
+package org.apache.kitty.ui
+
+/**
+ * <pre>
+ * <b>Description:</b>
+ * <p>
+ * The Dashboard class is the entry point to the GUI for the Apache Kitty 
JSR-160 implementation.  
+ * This class is incomplete at the time of the release of Apache Kitty 1.0 and 
will not be included in the production version of the project.  
+ * It may be included in development releases of this project.
+ * </p>
+ * </pre>
+ * 
+ * @author James R. Bray, Jr.
+ *
+ */
+class Dashboard {
+
+       /**
+        * 
+        */
+       public Dashboard() {
+               // TODO Auto-generated constructor stub
+       }
+
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/utils/Constants.java
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/utils/Constants.java?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/utils/Constants.java (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/utils/Constants.java Wed Nov 24 
01:33:10 2010
@@ -0,0 +1,19 @@
+package org.apache.kitty.utils;
+
+/**
+ * <pre>
+ * <b>Description</b>
+ * <p>
+ * Common constants used by the framework
+ * </p>
+ * </pre>
+ * 
+ * @author James R. Bray, Jr.
+ *
+ */
+public class Constants {
+       
+       public static final String ERROR_TOO_FEW_PARAMETERS = "You did not 
enter all of the required parameters for this command";
+       public static final String ERROR_NOT_CONNECTED = "Not currently 
connected to a host";
+
+}

Added: incubator/kitty/site/trunk/org/apache/kitty/utils/Help.groovy
URL: 
http://svn.apache.org/viewvc/incubator/kitty/site/trunk/org/apache/kitty/utils/Help.groovy?rev=1038425&view=auto
==============================================================================
--- incubator/kitty/site/trunk/org/apache/kitty/utils/Help.groovy (added)
+++ incubator/kitty/site/trunk/org/apache/kitty/utils/Help.groovy Wed Nov 24 
01:33:10 2010
@@ -0,0 +1,41 @@
+/**
+ * 
+ */
+package org.apache.kitty.utils
+
+
+/**
+ * @author James R. Bray, Jr.
+ *
+ */
+class Help {
+
+       /**
+        * 
+        */
+       public Help() {
+               toString()
+       }
+       
+       public String toString()
+       {
+               StringBuffer sb = new StringBuffer()
+               
+               sb.append "COMMANDS\n\n"
+               sb.append "connect <host> <port> - Connect to the remote host\n"
+               sb.append "disconnect - Disconnect from remote host\n"
+               sb.append "cd <path> - Change the current path\n"
+               sb.append "echo - Return the text that is entered\n"
+               sb.append "exit - Quit the application and return to the 
command prompt\n"
+               sb.append "get <attribute> - Get an attribute from the remote 
host\n"
+               sb.append "set <attribute> <value> - Set an attribute on the 
remote host\n"
+               sb.append "setdomain <domain> - Set the domain in the current 
session\n"
+               sb.append "invoke <operation> <parameters...> - Invoke an 
operation on the remote host\n"
+               sb.append "ls - List the managable resources on the remote 
host\n"
+               sb.append "pwd - \n"
+               
+               
+               return sb.toString()
+       }
+
+}


Reply via email to