Package org.jboss.as.demos

Examples of org.jboss.as.demos.DeploymentUtils$AbstractDeployment


* @version $Revision: 1.1 $
*/
public class ExampleRunner {

    public static void main(String[] args) throws Exception {
        DeploymentUtils deploymentUtils = null;
        try {
            deploymentUtils = new DeploymentUtils("sar-example.sar", ConfigService.class.getPackage());

            deploymentUtils.deploy();
            ObjectName objectName = new ObjectName("jboss:name=test,type=config");

            MBeanServerConnection mbeanServer = deploymentUtils.getConnection();

            //A little sleep to give the logging done by the bean time to kick in
            Thread.sleep(1500);

            System.out.println("Checking the IntervalSeconds property");
            Object o = mbeanServer.getAttribute(objectName, "IntervalSeconds");
            System.out.println("IntervalSeconds was " + o + ", setting it to 2");
            mbeanServer.setAttribute(objectName, new Attribute("IntervalSeconds", 2));
            System.out.println("IntervalSeconds set");

            //A little sleep to give the logging resulting from the new interval time to show up in the logs
            Thread.sleep(3000);
        } finally {
            deploymentUtils.undeploy();
            safeClose(deploymentUtils);
        }
    }
View Full Code Here


* @version $Revision: 1.1 $
*/
public class ExampleRunner {

    public static void main(String[] args) throws Exception {
        DeploymentUtils utils = null;
        try {
            EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class,"managedbean-example.ear");
            JavaArchive sar = ShrinkWrap.create(JavaArchive.class,"managedbean-mbean.sar");
            sar.addManifestResource("archives/managedbean-mbean.sar/META-INF/MANIFEST.MF", "MANIFEST.MF");
            sar.addManifestResource("archives/managedbean-mbean.sar/META-INF/jboss-service.xml", "jboss-service.xml");
            sar.addPackage(TestMBean.class.getPackage());
            ear.add(sar,"/");

            JavaArchive jar = ShrinkWrap.create(JavaArchive.class,"managedbean-example.jar");
            jar.addManifestResource("archives/managedbean-example.jar/META-INF/MANIFEST.MF", "MANIFEST.MF");
            jar.addManifestResource("archives/managedbean-example.jar/META-INF/services/org.jboss.msc.service.ServiceActivator", "services/org.jboss.msc.service.ServiceActivator");
            jar.addManifestResource(EmptyAsset.INSTANCE,"beans.xml");
            jar.addPackage(SimpleManagedBean.class.getPackage());
            ear.add(jar,"/");

            utils = new DeploymentUtils(ear);

            utils.deploy();
            ObjectName objectName = new ObjectName("jboss:name=test,type=managedbean");
            MBeanServerConnection mbeanServer = utils.getConnection();
            System.out.println("Calling echo(\"Hello\")");
            Object o = mbeanServer.invoke(objectName, "echo", new Object[] {"Hello"}, new String[] {"java.lang.String"});
            System.out.println("echo returned " + o);
        } finally {
            utils.undeploy();
            safeClose(utils);
        }
    }
View Full Code Here

        int count = (Integer) server.invoke(new ObjectName("jboss:name=ejb3-test,type=service"), "invokeSingleton", new Object[]{jndiName, numThreads, numTimes}, new String[]{String.class.getName(), Integer.TYPE.getName(), Integer.TYPE.getName()});
        System.out.println("Count is: " + count);
    }

    public static void main(String[] args) throws Exception {
        DeploymentUtils utils = new DeploymentUtils("ejb3-example.jar", SimpleStatelessSessionBean.class.getPackage());
        try {
            utils.addDeployment("ejb3-mbean.sar", Test.class.getPackage());
            utils.deploy();

            MBeanServerConnection mbeanServer = utils.getConnection();

            SimpleStatelessSessionLocal bean = createProxy(mbeanServer, "java:global/ejb3-example/SimpleStatelessSessionBean!" + SimpleStatelessSessionLocal.class.getName(), SimpleStatelessSessionLocal.class);
            String msg = bean.echo("Hello world");
            System.out.println(msg);

            exec(mbeanServer, ExerciseStateful.class);

            String singletonBeanJndiName = "java:global/ejb3-example/SimpleSingletonBean!" + SimpleSingletonLocal.class.getName();
            workOnSingletoBean(mbeanServer, singletonBeanJndiName, 100, 10);

            exec(mbeanServer, ExerciseBMT.class);
        } finally {
            utils.undeploy();
            safeClose(utils);
        }
    }
View Full Code Here

* @version $Revision: 1.1 $
*/
public class ExampleRunner {

    public static void main(String[] args) throws Exception {
        DeploymentUtils utils = null;
        try {
            utils = new DeploymentUtils();
            utils.addWarDeployment("ws-example.war", true, EndpointImpl.class.getPackage());
            utils.deploy();
            testWSDL();
            testSOAPCall();
            testWebServiceRef();
        } finally {
            utils.undeploy();
            safeClose(utils);
        }
    }
View Full Code Here

    public static void main(String[] args) throws Exception {
        QueueConnection conn = null;
        QueueSession session = null;
        ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9999);
        //TODO Don't do this FakeJndi stuff once we have remote JNDI working
        DeploymentUtils utils = null;
        boolean actionsApplied = false;
        try {
            utils = new DeploymentUtils("fakejndi.sar", FakeJndi.class.getPackage());
            utils.deploy();

            ModelNode op = new ModelNode();
            op.get("operation").set("add");
            op.get("address").add("subsystem", "jms");
            op.get("address").add("queue", QUEUE_NAME);
            op.get("entries").add(QUEUE_NAME);
            applyUpdate(op, client);
            actionsApplied = true;

            QueueConnectionFactory qcf = lookup(utils, "RemoteConnectionFactory", QueueConnectionFactory.class);
            Queue queue = lookup(utils, QUEUE_NAME, Queue.class);

            conn = qcf.createQueueConnection();
            conn.start();
            session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);

            // Set the async listener
            QueueReceiver recv = session.createReceiver(queue);
            recv.setMessageListener(new MessageListener() {

                @Override
                public void onMessage(Message message) {
                    TextMessage msg = (TextMessage)message;
                    try {
                        System.out.println("---->Received: " + msg.getText());
                    } catch (JMSException e) {
                        e.printStackTrace();
                    }
                }
            });

            QueueSender sender = session.createSender(queue);
            for (int i = 0 ; i < 10 ; i++) {
                String s = "Test" + i;
                System.out.println("----> Sending: " +s );
                TextMessage msg = session.createTextMessage(s);
                sender.send(msg);
            }

            Thread.sleep(1000);

        } finally {
            try {
                conn.stop();
            } catch (Exception ignore) {
            }
            try {
                session.close();
            } catch (Exception ignore) {
            }
            try {
                conn.close();
            } catch (Exception ignore) {
            }

            if(utils != null) {
                utils.undeploy();
            }
            safeClose(utils);
            if(actionsApplied) {
                // Remove the queue using the management API
                ModelNode op = new ModelNode();
View Full Code Here

* @version $Revision: 1.1 $
*/
public class ExampleRunner {

    public static void main(String[] args) throws Exception {
        DeploymentUtils utils = null;
        try {
            utils = new DeploymentUtils("rar-example.rar", true, HelloWorldConnection.class.getPackage());
            utils.addDeployment("rar-mbean.sar", true, Test.class.getPackage());

            utils.deploy();
            ObjectName objectName = new ObjectName("jboss:name=test,type=rar");


            //System.out.println(utils.showJndi());

            MBeanServerConnection mbeanServer = utils.getConnection();
            System.out.println("Calling TestMBean.helloWorld() on server");
            String s = (String)mbeanServer.invoke(objectName, "helloWorld", new Object[0], new String[0]);
            System.out.println("Received reply: " + s);

            System.out.println("Calling TestMBean.helloWorld(\"AS7\") on server");
            s = (String)mbeanServer.invoke(objectName, "helloWorld", new Object[] {"AS7"}, new String[] {"java.lang.String"});
            System.out.println("Received reply: " + s);
        } finally {
            utils.undeploy();
            safeClose(utils);
        }
    }
View Full Code Here

* @author <a href="mailto:jesper.pedersen@jboss.org">Jesper Pedersen</a>
*/
public class ExampleRunner {

    public static void main(String[] args) throws Exception {
        DeploymentUtils utils = null;
        try {
            utils = new DeploymentUtils("ds-mbean.sar", true, Test.class.getPackage());

            utils.deploy();
            ObjectName objectName = new ObjectName("jboss:name=test,type=ds");

            MBeanServerConnection mbeanServer = utils.getConnection();
            System.out.println("Calling TestMBean.test() on server");
            String s = (String) mbeanServer.invoke(objectName, "test", new Object[0], new String[0]);
            System.out.println("Received reply: " + s);
        } catch (Exception e) {
            Throwable parent = e;
            while (parent != null) {
                if (parent instanceof NameNotFoundException && e.getMessage().indexOf("H2DS") > -1) {
                    usage(parent);
                    return;
                }
                parent = parent.getCause();
            }
            e.printStackTrace();
        } finally {
            if (utils != null) {
                utils.undeploy();
            }
            safeClose(utils);
        }
    }
View Full Code Here

* @version $Revision: 1.1 $
*/
public class ExampleRunner {

    public static void main(String[] args) throws Exception {
        DeploymentUtils utils = null;
        try {
            utils = new DeploymentUtils("messaging-mbean.sar", Test.class.getPackage());
            //utils.addDeployment("jms-mbean.sar", Test.class.getPackage());

            utils.deploy();
            ObjectName objectName = new ObjectName("jboss:name=test,type=messaging");

            MBeanServerConnection mbeanServer = utils.getConnection();

            Thread.sleep(1000);
            System.out.println("Sending message: Test");
            mbeanServer.invoke(objectName, "sendMessage", new Object[] {"Test"}, new String[] {"java.lang.String"});
            Thread.sleep(1000);
            List<String> msgs = (List<String>)mbeanServer.invoke(objectName, "readMessages", new Object[] {"Test"}, new String[] {"java.lang.String"});
            System.out.println("Received messages: " + msgs);
        } finally {
            utils.undeploy();
            safeClose(utils);
        }
    }
View Full Code Here

* @version $Revision: 1.1 $
*/
public class ExampleRunner {

    public static void main(String[] args) throws Exception {
        DeploymentUtils utils = null;
        QueueConnection conn = null;
        QueueSession session = null;
        //TODO Don't do this FakeJndi stuff once we have remote JNDI working
        try {
            utils = new DeploymentUtils("fakejndi.sar", FakeJndi.class.getPackage());
            utils.addWarDeployment("webapp-example.war", SimpleServlet.class.getPackage());
            utils.deploy();

            QueueConnectionFactory qcf = lookup(utils, "RemoteConnectionFactory", QueueConnectionFactory.class);
            Queue queue = lookup(utils, "queue/test", Queue.class);
            conn = qcf.createQueueConnection();
            conn.start();
            session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);

            // Set the async listener
            QueueReceiver recv = session.createReceiver(queue);
            recv.setMessageListener(new MessageListener() {

                @Override
                public void onMessage(Message message) {
                    TextMessage msg = (TextMessage)message;
                    try {
                        System.out.println("---->Received from queue: " + msg.getText());
                    } catch (JMSException e) {
                        e.printStackTrace();
                    }
                }
            });


            connect("other?value=One");
            connect("simple?value=Two");
            connect("other?value=Three");
        } finally {
            utils.undeploy();
            safeClose(utils);
            if(conn != null) {
                conn.close();
            }
        }
View Full Code Here

* @author Emanuel Muckenhuber
*/
public class ExampleRunner {

    public static void main(String[] args) throws Exception {
        DeploymentUtils utils = null;
        final ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9999);
        try {
            utils = new DeploymentUtils();
            utils.addWarDeployment("war-example.war", true, SimpleServlet.class.getPackage());
            utils.deploy();

            // Create the test connector
            createTestConnector(client);

            URLConnection conn = null;
            InputStream in = null;
            try {
                // Use the created connector on port 8380
                URL url = new URL("http://localhost:8380/war-example/simple?input=Hello");
                System.out.println("Reading response from " + url + ":");
                conn = url.openConnection();
                conn.setDoInput(true);
                in = new BufferedInputStream(conn.getInputStream());
                int i = in.read();
                while (i != -1) {
                    System.out.print((char)i);
                    i = in.read();
                }
                System.out.println("");
            } finally {
                safeClose(in);
            }

            // And remove the connector again
            removeTestConnector(client);

        } finally {
            utils.undeploy();
            safeClose(utils);
            safeClose(client);
        }

    }
View Full Code Here

TOP

Related Classes of org.jboss.as.demos.DeploymentUtils$AbstractDeployment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.