Search in sources :

Example 1 with TelnetListener

use of org.jboss.as.test.integration.ejb.mdb.dynamic.api.TelnetListener 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)

Aggregations

IOException (java.io.IOException)1 ResourceException (javax.resource.ResourceException)1 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)1 Work (javax.resource.spi.work.Work)1 TelnetListener (org.jboss.as.test.integration.ejb.mdb.dynamic.api.TelnetListener)1 TelnetServer (org.jboss.as.test.integration.ejb.mdb.dynamic.impl.TelnetServer)1