开发者

how to handle configuration for accept and production environment in glassfish

I want to create an application that is not aware of the environment it runs in. The environment 开发者_开发百科specific configuration I want to leave up to the configuration of glassfish.

So eg I have a persistence.xml which 'points' to a jta data source

<jta-data-source>jdbc/DB_PRODUCTSUPPLIER</jta-data-source>

In glassfish this datasource is configured to 'point' to a connection pool. This connection pool is configured to connect to a database.

I would like to have a mechanism such that I can define these resources for a production and an accept environment without having to change the jndi name. Because this would mean that my application is environment aware.

Do I need to create two domains for this? Or do I need two completely separate glassfish installations?


One way to do this is to use clustering features (GF 2.1 default install is often developer mode, so you'll have to enable clustering, GF 3.1 clustering seems to be on by default).

As part of clustering, you can create stand alone instances that do not participate in a cluster. Each instance can have its own config. These instances share everything under the Resources section, and each instance can have separate values in the system properties, most importantly these are separate port numbers.

So a usage scenario would be that your accept/beta environment will run on it's own instance with different ports (defaults being 38080, 38181, etc., assuming you're doing an http app). When running this way, your new instance will be running in a separate JVM. With GF 2.1, you need to learn how to manage the node agent. With GF 3.1, you won't have to worry about that.

When you deploy an application, you must choose the destination, called a Target, so you can have an accept/beta version on one instance, and a production version on the other instance.

This is how I run beta deployments with our current GF 2.1 non-clustered setup and it works pretty well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜