use of org.glassfish.api.event.EventListener in project Payara by payara.
the class ShoalBackingStoreProxy method postConstruct.
@Override
public void postConstruct() {
BackingStoreFactoryRegistry.register("replicated", this);
Logger.getLogger(ShoalBackingStoreProxy.class.getName()).log(Level.FINE, "Registered SHOAL BackingStore Proxy with persistence-type = replicated");
EventListener glassfishEventListener = new EventListener() {
@Override
public void event(Event event) {
if (event.is(EventTypes.SERVER_SHUTDOWN)) {
BackingStoreFactoryRegistry.unregister("replicated");
Logger.getLogger(ShoalBackingStoreProxy.class.getName()).log(Level.FINE, "Unregistered SHOAL BackingStore Proxy with persistence-type = replicated");
}
// else if (event.is(EventTypes.SERVER_READY)) { }
}
};
events.register(glassfishEventListener);
}
use of org.glassfish.api.event.EventListener in project Payara by payara.
the class ConnectorsClassLoaderUtil method createRARClassLoader.
private ConnectorClassFinder createRARClassLoader(final ClassLoader parent, String moduleDir, final String moduleName, List<URI> appLibs) throws ConnectorRuntimeException {
ConnectorClassFinder cl = null;
try {
final DelegatingClassLoader.ClassFinder librariesCL = getLibrariesClassLoader(appLibs);
cl = (ConnectorClassFinder) AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
final ConnectorClassFinder ccf = new ConnectorClassFinder(parent, moduleName, librariesCL);
if (processEnv.getProcessType().isEmbedded()) {
events.register(new EventListener() {
public void event(Event event) {
if (event.is(EventTypes.PREPARE_SHUTDOWN)) {
ccf.done();
}
}
});
}
return ccf;
}
});
} catch (Exception ex) {
_logger.log(Level.SEVERE, "error.creating.connector.classloader", ex);
ConnectorRuntimeException cre = new ConnectorRuntimeException(ex.getMessage());
cre.initCause(ex);
throw cre;
}
File file = new File(moduleDir);
try {
cl.appendURL(file.toURI().toURL());
appendJars(file, cl);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
return cl;
}
use of org.glassfish.api.event.EventListener in project Payara by payara.
the class GlassFishORBHelper method setORB.
public synchronized void setORB(ORB orb) {
this.orb = orb;
if (orb != null) {
EventListener glassfishEventListener = new org.glassfish.api.event.EventListener() {
public void event(org.glassfish.api.event.EventListener.Event event) {
if (event.is(EventTypes.SERVER_SHUTDOWN)) {
onShutdown();
}
}
};
eventsProvider.get().register(glassfishEventListener);
}
}
use of org.glassfish.api.event.EventListener in project Payara by payara.
the class TransactionLifecycleService method postConstruct.
@Override
public void postConstruct() {
EventListener glassfishEventListener = new EventListener() {
@Override
public void event(Event event) {
if (event.is(EventTypes.SERVER_READY)) {
_logger.fine("TM LIFECYCLE SERVICE - ON READY");
onReady();
} else if (event.is(EventTypes.PREPARE_SHUTDOWN)) {
_logger.fine("TM LIFECYCLE SERVICE - ON SHUTDOWN");
onShutdown();
}
}
};
events.register(glassfishEventListener);
if (nm != null) {
try {
nm.publishObject(USER_TX_NO_JAVA_COMP, new NamingObjectProxy.InitializationNamingObjectProxy() {
@Override
public Object create(Context ic) throws NamingException {
ActiveDescriptor<?> descriptor = habitat.getBestDescriptor(BuilderHelper.createContractFilter("javax.transaction.UserTransaction"));
if (descriptor == null)
return null;
return habitat.getServiceHandle(descriptor).getService();
}
}, false);
} catch (NamingException e) {
_logger.warning("Can't bind \"UserTransaction\" in JNDI");
}
}
}
use of org.glassfish.api.event.EventListener in project Payara by payara.
the class EventsTest method deployUndeployTest.
@Test
public void deployUndeployTest() throws Exception {
final List<EventTypes> myTestEvents = getSingletonModuleSuccessfullDeploymentEvents();
Events events = habitat.getService(Events.class);
EventListener listener = new EventListener() {
public void event(Event event) {
if (myTestEvents.contains(event.type())) {
myTestEvents.remove(event.type());
}
}
};
events.register(listener);
Deployment deployment = habitat.getService(Deployment.class);
DeployCommandParameters params = new DeployCommandParameters(application);
params.name = "fakeApplication";
params.target = "server";
ActionReport report = habitat.getService(ActionReport.class, "hk2-agent");
ExtendedDeploymentContext dc = deployment.getBuilder(Logger.getAnonymousLogger(), params, report).source(application).build();
deployment.deploy(dc);
events.unregister(listener);
for (EventTypes et : myTestEvents) {
System.out.println("An expected event of type " + et.type() + " was not received");
}
try {
final List<EventTypes> myTestEvents2 = getSingletonModuleSuccessfullUndeploymentEvents();
EventListener listener2 = new EventListener() {
public void event(Event event) {
if (myTestEvents2.contains(event.type())) {
myTestEvents2.remove(event.type());
}
}
};
events.register(listener2);
UndeployCommandParameters params2 = new UndeployCommandParameters("fakeApplication");
params2.target = "server";
ActionReport report2 = habitat.getService(ActionReport.class, "hk2-agent");
ExtendedDeploymentContext dc2 = deployment.getBuilder(Logger.getAnonymousLogger(), params2, report2).source(application).build();
deployment.undeploy("fakeApplication", dc2);
events.unregister(listener2);
for (EventTypes et : myTestEvents2) {
System.out.println("An expected event of type " + et.type() + " was not received");
}
} catch (Throwable t) {
t.printStackTrace();
}
}
Aggregations