Glassfish v3.1: LifecycleListener vs. Startup.Listener - listener

How to correctly call my code when Glassfish v3.x is READY or going to SHUTDOWN?
I was succesfully using lifecycle listener on glassfish v2.x.
Unfortunatelly, this interface is marked as DEPRECATED in Glassfish v3.x. A new interface Startup is recomended instead but I don't know how to use it and could not find any useful documentation or examples. Could you please point me to how use it?

You want what's called a lifecycle module. Chapter 12, Developing Lifecycle Listeners is a good place to start. This explains the available events and when they fire. Once you have your class codded and ready to go this blog entry will explain how to deploy the module to GlassFish using the admin console..

Related

Library class doesn't know of ConfigureWebHostDefaults extension method

I'm building a suite of REST micro-services using .Net Core 3.0 Preview 6. All these services will have the same start up logic. So, I'm trying to place all the code in a .Net Standard library.
The goal is to have the IHostBuilder:CreateHostBuilder method, as well as the Startup:Configure and Startup:ConfigureServices class and methods in the library. The library will also contain error handling logic, customized http response messages, etc.
However, I can't seem to find the correct package that contains the ConfigureWebHostDefaults method. I tried adding the Microsoft.AspNetCore package 2.2.0, but that didn't resolve the issue.
I added the Microsoft.Extensions.Hosting (3.0.0-preview-6) package, that also doesn't resolve the issue.
Is what I'm attempting even possible?
Thanks
-marc
I resolved it, not the best way, but it works. I decided to make the library targeted specifically for .NET Core 3.0. So, I changed the targetframework in the project file. That change automatically resolved my other issue.
Import the Microsoft.AspNetCore package, and use WebHost.CreateDefaultBuilder() instead. According to the code it is built from, both CreateDefaultBuilder() and ConfigureWebHostDefaults() call the same internal method: ConfigureWebDefaults().
The only downside of this is that the returned host will be an IWebHost instead of an IHost.

What Angular Providers do and how to use it?

I'm new with Angular. I follow a tutorial from this link, and i tried to do/add something that doesn't part of that tutorial. I added a providers :[EmployeeService] line to employee-list.component.ts and empployee.component.ts inside #component, and it returns error that said TypeError: Cannot read property 'push' of undefined. So realize that adding providers :[EmployeeService] to some components are unnecessary. I read about Dependency Injection from this link but i do not really get what i wanted to know. So can anyone give me a simple explanation how/when/where to use/put providers and how that error happens?
Thank you very much in advance.
providers array tells Angular what services it should instantiate. You can define it on two places:
component
module
When you use providers in component the service will be available to that and all it's children.
When you use it in module the service will be available for all pipes, directives, components and services in given module.
But you can define it in both if you want - in that case Angular will create two instances of the same service.
For beginning provide your services on the module level.

JUnit Testing with bean injection

I am trying to test my web application using JUnit. I saw that there is cdi-unit which seems pretty nice or Arquillian with JBoss (I am on Seam3, JBoss 7.1.3) but I can't make it work.
As soon as I try to inject a bean (and I need to inject multiple beans for my tests), it isn't working. I get "unsatisfied injection for type[...] with qualifiers [#default] at injection point".
Especially for the EntityManager which I need to inject. Is there some easy plugin I can add to my pom file in order to get this working ?
Thanks !
You should have a look at the DeltaSpike Test Control module. This will start an embedded CDI container in your test. It is really simple to set up.
Have a look at the module documentation here:
http://deltaspike.apache.org/documentation/test-control.html

Why does importing javafx.scene.control.Button fail with Toolkit Not Initialized?

I'm trying basic stuff with JavaFX with Clojure, on Java8 64-bit (1.8.0_05-b13) on Windows 7.
In my imports (whether in .clj file or in REPL), I can (import 'javafx.scene.control.ButtonBuilder) (and other builders), but I cannot (import 'javafx.scene.control.Button) or any other final widget from javax.scene.control.
If I try importing javafx.scene.control.Button or other widget, I get the Toolkit Not Initialized error. Same with trying to create the button via the ButtonBuilder, even though the ButtonBuilder class itself seems to work fine, and it appears I'm quite able to import other things from the javafx heirarchy.
In order to get it to work I have to force the toolkit to initialize, as shown here, which I think leaves me with an Orphan panel somewhere, which feels kind of dirty: https://gist.github.com/zilti/6286307
(ns hello.core
(:import (javafx.event ActionEvent EventHandler)
(javafx.scene Scene SceneBuilder)
(javafx.scene.layout VBox VBoxBuilder)
;;(javafx.scene.control Button) -- MUST COMMENT THIS OUT OR FAIL
(javafx.scene.control ButtonBuilder)
(javafx.stage Stage StageBuilder)))
(defonce force-toolkit-init (javafx.embed.swing.JFXPanel.))
This was not the case with Java 7 and javafxrt.jar. The only discussion about this I've found (on SO) shows this is required for Swing interop, which I'm not using.
Can someone please explain why this is required now with Java8, and why it only seems to be required for final widgets like Button?
This looks like a magic workaround. Is there a real solution somehow?
JavaFX requires initialization code which starts UI threads, handles application running modes and load native libraries.
JavaFX application are strongly advised to start from a class extending javafx.appication.Application which will perform all initialization routines.
Calling JFXPanel will perform initialization too but it's kinda hack (unless you are really using swing and FX in one app).

PerWebRequest and Transient lifeStyles

Can someone please help me understand several things?
Do I still have to register PerRequestModule to use
LifeStylePerWebRequest? I use Castle.Windsor 3.2.0.0 and it seems
everything works without this module. I definetly remember that
there was an exception before that tells me "You forget to register
this module".
What "objects tracked by release policy" really
means? I use several Components with LifeStyleTransient but when I
Resolve one I get it in "objects tracked by release policy"
property, when I Resolve others I don't get them there.
How can I check the actual objects stored inside the container (and their
number)?
1) I guess since version 3.x PerRequestModule will be automatically registered by windsor.
2) An object will be tracked by windsor only if needed(for ex if its lifestyle is Transient and it implements IDisposable interface).
3) You can run unit tests checking for handlers or manually set a debug point once you registered all components and navigate with VS viewer container object: it has a property that lists all registered components.