Package org.jboss.as.demos

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


* @author Emanuel Muckenhuber
*/
public class ExampleRunner {

    public static void main(String[] args) throws Exception {
        DeploymentUtils utils = null;
        try {
            utils = new DeploymentUtils();
            ModelControllerClient client = utils.getClient();
            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);
        }

    }
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.addAsManifestResource("archives/managedbean-mbean.sar/META-INF/MANIFEST.MF", "MANIFEST.MF");
            sar.addAsManifestResource("archives/managedbean-mbean.sar/META-INF/jboss-service.xml", "jboss-service.xml");
            sar.addPackage(TestMBean.class.getPackage());
            ear.add(sar, "/", ZipExporter.class);

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

            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

* @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

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {
        DeploymentUtils deploymentUtils = null;

        try {
            deploymentUtils = new DeploymentUtils("ear-example.ear", ConfigService.class.getPackage());
            deploymentUtils.deploy();

        }finally{
            deploymentUtils.undeploy();
            safeClose(deploymentUtils);

        }

    }
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();
            utils.addWarDeployment("ws-example.war", true, EndpointImpl.class.getPackage());
            utils.deploy();
            testWebServiceRef();
            testAccess();
        } 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("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;
        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

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

   public static void main(String[] args) throws Exception {
      DeploymentUtils utils = null;
      try {
         utils = new DeploymentUtils();
         utils.addWarDeployment("jaxrs-example.war", true, HelloWorldResource.class.getPackage());
         utils.deploy();
         performCall();
      } finally{
         utils.undeploy();
         safeClose(utils);
      }
   }
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.