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;
}
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);
}
}
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();
}
Aggregations