[jboss-cvs] JBoss Messaging SVN: r3384 - branches/Branch_MC_Integration_New/src/main/org/jboss/jms/client/admin.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 28 14:21:43 EST 2007
Author: ataylor
Date: 2007-11-28 14:21:43 -0500 (Wed, 28 Nov 2007)
New Revision: 3384
Added:
branches/Branch_MC_Integration_New/src/main/org/jboss/jms/client/admin/Admin.java
Log:
new admin class
Added: branches/Branch_MC_Integration_New/src/main/org/jboss/jms/client/admin/Admin.java
===================================================================
--- branches/Branch_MC_Integration_New/src/main/org/jboss/jms/client/admin/Admin.java (rev 0)
+++ branches/Branch_MC_Integration_New/src/main/org/jboss/jms/client/admin/Admin.java 2007-11-28 19:21:43 UTC (rev 3384)
@@ -0,0 +1,80 @@
+/*
+ * 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.jms.client.admin;
+
+import org.jboss.jms.server.JmsServer;
+import org.jboss.jms.server.JmsServerStatistics;
+
+import javax.naming.InitialContext;
+import java.lang.reflect.Proxy;
+import java.util.Hashtable;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class Admin
+{
+ private InitialContext initialContext;
+ private String user;
+ private String password;
+ public void connect(InitialContext initialContext)
+ {
+ connect(initialContext, null, null);
+ }
+
+ public void connect(InitialContext initialContext, String user, String password)
+ {
+ this.initialContext = initialContext;
+ this.user = user;
+ this.password = password;
+ }
+
+ public JmsServer getServer()
+ {
+ return (JmsServer) Proxy.newProxyInstance(JmsServer.class.getClassLoader(),
+ new Class[] { JmsServer.class },
+ new JmsServerInvocationHandler(initialContext));
+
+ }
+
+ public JmsServerStatistics getServerStatistics()
+ {
+ return (JmsServerStatistics) Proxy.newProxyInstance(JmsServerStatistics.class.getClassLoader(),
+ new Class[] { JmsServerStatistics.class },
+ new JmsServerStatisticsInvocationHandler());
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ Admin admin = new Admin();
+ Hashtable env = new Hashtable();
+ env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ env.put("java.naming.provider.url", "jnp://localhost:1099");
+ env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
+
+ InitialContext ic = new InitialContext(env);
+ admin.connect(ic);
+ JmsServer server = admin.getServer();
+ System.out.println(server.getJMSMajorVersion());
+ System.out.println(server.deployQueue("andy", "andy"));
+ }
+}
More information about the jboss-cvs-commits
mailing list