Search in sources :

Example 1 with TelnetServer

use of org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer in project wildfly by wildfly.

the class DynamicMessageListenerTestCase method createDeplyoment.

@Deployment
public static Archive createDeplyoment() {
    final EnterpriseArchive ear = create(EnterpriseArchive.class, "ear-with-rar.ear").addAsModule(create(JavaArchive.class, "telnet-ra.rar").addAsManifestResource(TelnetResourceAdapter.class.getPackage(), "ra.xml", "ra.xml").addPackages(true, TelnetResourceAdapter.class.getPackage(), TelnetListener.class.getPackage(), TelnetServer.class.getPackage())).addAsModule(create(JavaArchive.class, "mdb.jar").addClasses(MyMdb.class));
    ear.addAsManifestResource(createPermissionsXmlAsset(// Cmd (TelnetServer package) uses PropertyEditorManager#registerEditor during static initialization
    new PropertyPermission("*", "read,write"), // TelnetServer binds socket and accepts connections
    new SocketPermission("*", "accept,listen")), "permissions.xml");
    return ear;
}
Also used : EnterpriseArchive(org.jboss.shrinkwrap.api.spec.EnterpriseArchive) TelnetResourceAdapter(org.jboss.as.test.integration.ejb.mdb.dynamic.adapter.TelnetResourceAdapter) PropertyPermission(java.util.PropertyPermission) TelnetListener(org.jboss.as.test.integration.ejb.mdb.dynamic.api.TelnetListener) SocketPermission(java.net.SocketPermission) MyMdb(org.jboss.as.test.integration.ejb.mdb.dynamic.application.MyMdb) TelnetServer(org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 2 with TelnetServer

use of org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer in project wildfly by wildfly.

the class TelnetResourceAdapter method endpointActivation.

@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
    final TelnetActivationSpec telnetActivationSpec = (TelnetActivationSpec) activationSpec;
    final MessageEndpoint messageEndpoint = messageEndpointFactory.createEndpoint(null);
    // This messageEndpoint instance is also castable to the ejbClass of the MDB
    final TelnetListener telnetListener = (TelnetListener) messageEndpoint;
    try {
        final TelnetServer telnetServer = new TelnetServer(telnetActivationSpec, telnetListener, port);
        workManager.scheduleWork(new Work() {

            @Override
            public void release() {
            }

            @Override
            public void run() {
                try {
                    telnetServer.activate();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }, 0, null, null);
        activated.put(port, telnetServer);
    } catch (IOException e) {
        throw new ResourceException(e);
    }
}
Also used : MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) TelnetListener(org.jboss.as.test.integration.ejb.mdb.dynamic.api.TelnetListener) Work(javax.resource.spi.work.Work) ResourceException(javax.resource.ResourceException) IOException(java.io.IOException) TelnetServer(org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer)

Example 3 with TelnetServer

use of org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer in project wildfly by wildfly.

the class TelnetResourceAdapter method endpointDeactivation.

@Override
public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
    final TelnetActivationSpec telnetActivationSpec = (TelnetActivationSpec) activationSpec;
    final TelnetServer telnetServer = activated.remove(port);
    try {
        telnetServer.deactivate();
    } catch (IOException e) {
        e.printStackTrace();
    }
    final MessageEndpoint endpoint = (MessageEndpoint) telnetServer.getListener();
    endpoint.release();
}
Also used : MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) IOException(java.io.IOException) TelnetServer(org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer)

Aggregations

TelnetServer (org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer)3 IOException (java.io.IOException)2 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)2 TelnetListener (org.jboss.as.test.integration.ejb.mdb.dynamic.api.TelnetListener)2 SocketPermission (java.net.SocketPermission)1 PropertyPermission (java.util.PropertyPermission)1 ResourceException (javax.resource.ResourceException)1 Work (javax.resource.spi.work.Work)1 Deployment (org.jboss.arquillian.container.test.api.Deployment)1 TelnetResourceAdapter (org.jboss.as.test.integration.ejb.mdb.dynamic.adapter.TelnetResourceAdapter)1 MyMdb (org.jboss.as.test.integration.ejb.mdb.dynamic.application.MyMdb)1 EnterpriseArchive (org.jboss.shrinkwrap.api.spec.EnterpriseArchive)1