By dochez on Mar 07, 2009
I am embarking on an attempt to describe some of the extensibility points that GlassFish v3 has to offer. In this first article, I will describe how you can deploy raw unmodified grizzly adapters like any other GlassFish application.
As you probably know, GlassFish v3 is built on top of grizzly, yet up to now, it was not possibly to deploy a native Grizzly adapter directly inside V3.
Jean Francois was asking me to add this support some time back so people could leverage investments they made in developing grizzly extensions by using them in an application server that will soon support clustering and other goodies out of reach for the grizzly community.
As usual with GlassFish V3, now Grizzly applications are treated just like any other applications and you can use familiar tools to manage them.
So, to run your favorite adapter, you simply have to declare it using a small XML file, using the following format
<adapters> <adapter context-root="/cometd" class-name="com.foo.bar.CometdAdapter"> </adapter> </adapters>
you can also initialize the adapter with the following Beans type of pattern :
<adapter ...> <property name="foo" value="bar"/> </adapter>
Internally Adapter.set<name> = <value> will be called, like:
Of course, you can place as many adapters as you want in the xml file. Finally, place the xml file inside your jar at META-INF/grizzly-glassfish.xml and then using the latest snasphot build , just deploy your jar file or directory like any other GlassFish application :
asadmin deploy adapter.jar OR asadmin deploy myadapterdirectory
Please note that the context-root parameter on the deploy command is not applying to grizzly applications since they can have multiple adapters at multiple context-roots.
Now, Jean Francois has already developed some extensions so folks can also start deploying grizzlet directly into GlassFish, more to come from him. The source code for the grizzly container is about 5 classes, and it is a great example on how to extend the GlassFish application server to add support for new application types, find it here.