@Before public void setUp() throws SQLException, NoSuchMethodException { when(dataSource.getConnection()).thenReturn(connection); when(appEvent.getType()).thenReturn(ApplicationEvent.Type.INITIALIZATION_APP_FINISHED); when(requestFinishEvent.getType()).thenReturn(RequestEvent.Type.FINISHED); when(requestMethodExceptionEvent.getType()).thenReturn(RequestEvent.Type.ON_EXCEPTION); when(requestFinishEvent.getUriInfo()).thenReturn(uriInfo); when(requestMethodExceptionEvent.getUriInfo()).thenReturn(uriInfo); when(containerRequest.getProperty(ConfigurationFactory.CONNECTION_PROVIDER_PROPERTY)).thenReturn(connectionProvider); when(requestFinishEvent.getContainerRequest()).thenReturn(containerRequest); when(requestMethodExceptionEvent.getContainerRequest()).thenReturn(containerRequest); requestFinishEvent.getContainerRequest().getProperty(ConfigurationFactory.CONNECTION_PROVIDER_PROPERTY); }
@Override public void onEvent(final ApplicationEvent event) { if (event.getType() == ApplicationEvent.Type.INITIALIZATION_APP_FINISHED) { event.getResourceModel().getResources().parallelStream() .filter(Objects::nonNull) .forEach(resource -> { this.registerCircuitBreakerAnnotations(resource.getAllMethods()); resource.getChildResources().parallelStream() .filter(Objects::nonNull) .forEach(childResource -> { this.registerCircuitBreakerAnnotations( childResource.getAllMethods()); }); }); } }
@Override public void onEvent(ApplicationEvent applicationEvent) { switch (applicationEvent.getType()) { case INITIALIZATION_START: logger.info("Initialization started"); break; case INITIALIZATION_FINISHED: logger.info("Initialization finished"); break; case INITIALIZATION_APP_FINISHED: logger.info("Initialization of APP finished"); break; case RELOAD_FINISHED: logger.info("Reload completed"); break; case DESTROY_FINISHED: logger.info("Destroy completed"); break; } }
@Before public void setUp() throws Exception { when(sessionFactory.openSession()).thenReturn(session); when(session.getSessionFactory()).thenReturn(sessionFactory); when(session.beginTransaction()).thenReturn(transaction); when(session.getTransaction()).thenReturn(transaction); when(transaction.isActive()).thenReturn(true); when(appEvent.getType()).thenReturn(ApplicationEvent.Type.INITIALIZATION_APP_FINISHED); when(requestMethodStartEvent.getType()).thenReturn(RequestEvent.Type.RESOURCE_METHOD_START); when(responseFiltersStartEvent.getType()).thenReturn(RequestEvent.Type.RESP_FILTERS_START); when(requestMethodExceptionEvent.getType()).thenReturn(RequestEvent.Type.ON_EXCEPTION); when(requestMethodStartEvent.getUriInfo()).thenReturn(uriInfo); when(responseFiltersStartEvent.getUriInfo()).thenReturn(uriInfo); when(requestMethodExceptionEvent.getUriInfo()).thenReturn(uriInfo); prepareAppEvent("methodWithDefaultAnnotation"); }
@Override public void onEvent(ApplicationEvent event) { if (event.getType() == ApplicationEvent.Type.INITIALIZATION_APP_FINISHED) { final ResourceModel resourceModel = event.getResourceModel(); final ResourceLogDetails logDetails = new ResourceLogDetails(); resourceModel.getResources().stream().forEach((resource) -> { logDetails.addEndpointLogLines(getLinesFromResource(resource)); }); logDetails.log(); } }
@Override public synchronized void onEvent(ApplicationEvent applicationEvent) { if (applicationEvent.getType().equals(INITIALIZATION_FINISHED)) { String applicationName = applicationEvent.getResourceConfig().getApplicationName(); LOGGER.info("Application '{}' was initialized.", applicationName); } }
@Before public void setUp() throws Exception { this.listener.registerBundle(RemoteCredentialHibernateBundle.DEFAULT_NAME, this.bundle); this.listener.registerBundle("analytics", this.analyticsBundle); final SessionHolders sessionHolders = mock(SessionHolders.class); when(this.bundle.getSessionHolders()).thenReturn(sessionHolders); when(this.analyticsBundle.getSessionHolders()).thenReturn(sessionHolders); when(this.bundle.getSessionFactory()).thenReturn(this.sessionFactory); when(this.analyticsBundle.getSessionFactory()) .thenReturn(this.analyticsSessionFactory); when(this.sessionFactory.openSession()).thenReturn(this.session); when(this.session.getSessionFactory()).thenReturn(this.sessionFactory); when(this.session.beginTransaction()).thenReturn(this.transaction); when(this.session.getTransaction()).thenReturn(this.transaction); when(this.transaction.isActive()).thenReturn(true); when(this.analyticsSessionFactory.openSession()).thenReturn(this.analyticsSession); when(this.analyticsSession.getSessionFactory()).thenReturn(this.analyticsSessionFactory); when(this.analyticsSession.beginTransaction()).thenReturn(this.analyticsTransaction); when(this.analyticsSession.getTransaction()).thenReturn(this.analyticsTransaction); when(this.analyticsTransaction.isActive()).thenReturn(true); when(this.appEvent.getType()).thenReturn(ApplicationEvent.Type.INITIALIZATION_APP_FINISHED); when(this.requestMethodStartEvent.getType()) .thenReturn(RequestEvent.Type.RESOURCE_METHOD_START); when(this.responseFiltersStartEvent.getType()) .thenReturn(RequestEvent.Type.RESP_FILTERS_START); when(this.requestMethodExceptionEvent.getType()).thenReturn(RequestEvent.Type.ON_EXCEPTION); when(this.requestMethodStartEvent.getUriInfo()).thenReturn(this.uriInfo); when(this.responseFiltersStartEvent.getUriInfo()).thenReturn(this.uriInfo); when(this.requestMethodExceptionEvent.getUriInfo()).thenReturn(this.uriInfo); this.prepareAppEvent("methodWithDefaultAnnotation"); }
@Override public void onEvent(ApplicationEvent applicationEvent) { if (applicationEvent.getType() == Type.INITIALIZATION_START) { // Request all implementations of the contract from HK2 and activate them activateComponents(); } }
@Override public void onEvent(ApplicationEvent applicationEvent) { if (parameterMap == null && applicationEvent.getType() == ApplicationEvent.Type.INITIALIZATION_START) { Set<Class<?>> providers = applicationEvent.getProviders(); ClassLoader classLoader = applicationEvent.getResourceConfig().getClassLoader(); parameterMap = buildParameterMap(providers, classLoader); } }
@Override public void onEvent(ApplicationEvent event) { switch (event.getType()) { case INITIALIZATION_FINISHED: LOG.info("Application " + event.getResourceConfig().getApplicationName() + " initialization finished."); break; case DESTROY_FINISHED: LOG.info("Application "+ event.getResourceConfig().getApplicationName()+" destroyed."); break; default: break; } }
@Override public void onEvent(ApplicationEvent event) { if (event.getType() == ApplicationEvent.Type.INITIALIZATION_APP_FINISHED) { for (Resource resource : event.getResourceModel().getResources()) { resource.getAllMethods().forEach(this::registerUnitOfWorkAnnotations); for (Resource childResource : resource.getChildResources()) { childResource.getAllMethods().forEach(this::registerUnitOfWorkAnnotations); } } } }
@SuppressWarnings("unchecked") @Before public void setUp() throws Exception { listener.registerEntityManagerFactory(EntityManagerBundle.DEFAULT_NAME, entityManagerFactory); listener.registerEntityManagerFactory("analytics", analyticsEntityManagerFactory); when(entityManagerFactory.createEntityManager()).thenReturn(entityManager); when(entityManager.getEntityManagerFactory()).thenReturn(entityManagerFactory); when(entityManager.getSession()).thenReturn(session); when(entityManager.getTransaction()).thenReturn(transaction); when(transaction.isActive()).thenReturn(true); when(analyticsEntityManagerFactory.createEntityManager()).thenReturn(analyticsEntityManager); when(analyticsEntityManager.getEntityManagerFactory()).thenReturn(analyticsEntityManagerFactory); when(analyticsEntityManager.getSession()).thenReturn(analyticsSession); when(analyticsEntityManager.getTransaction()).thenReturn(analyticsTransaction); when(analyticsTransaction.isActive()).thenReturn(true); when(appEvent.getType()).thenReturn(ApplicationEvent.Type.INITIALIZATION_APP_FINISHED); when(requestMethodStartEvent.getType()).thenReturn(RequestEvent.Type.RESOURCE_METHOD_START); when(responseFiltersStartEvent.getType()).thenReturn(RequestEvent.Type.RESP_FILTERS_START); when(responseFinishedEvent.getType()).thenReturn(RequestEvent.Type.FINISHED); when(requestMethodExceptionEvent.getType()).thenReturn(RequestEvent.Type.ON_EXCEPTION); when(requestMethodStartEvent.getUriInfo()).thenReturn(uriInfo); when(responseFiltersStartEvent.getUriInfo()).thenReturn(uriInfo); when(responseFinishedEvent.getUriInfo()).thenReturn(uriInfo); when(requestMethodExceptionEvent.getUriInfo()).thenReturn(uriInfo); prepareAppEvent("methodWithDefaultAnnotation"); }
@Override public void onEvent(ApplicationEvent event) { switch (event.getType()) { case INITIALIZATION_FINISHED: log.info("Application {} was initialized.", event.getResourceConfig().getApplicationName()); break; case DESTROY_FINISHED: log.info("Application {} was destroyed", event.getResourceConfig().getApplicationName()); break; default: break; } }
@Override public void onEvent(ApplicationEvent event) { }
@Override public void onEvent(ApplicationEvent event) { logger.info("ApplicationEventListener.onEvent " + event.getType()); }
@Override public void onEvent(ApplicationEvent applicationEvent) { }
@Override public void onEvent(ApplicationEvent event) { if (event.getType() == ApplicationEvent.Type.INITIALIZATION_START) { serviceLocator.inject(hk2ValidationBundle); } }
@Override public void onEvent(ApplicationEvent event) { SystemEventBus.publish(new ameba.core.event.ApplicationEvent(event)); }
@Override public void onEvent(final ApplicationEvent applicationEvent) {}