The GlassFish Server provides built-in factories for the following types of custom resources:
Template sun-resources.xml files for these built-in factories and a README file are available at as-install/lib/install/templates/resources/custom/. For more information about the sun-resources.xml file, see the Oracle GlassFish Server 3.0.1 Application Deployment Guide.
To create a custom resource that provides instances of a JavaBean class, follow these steps:
Set the custom resource's factory class to org.glassfish.resources.custom.factory.JavaBeanFactory.
Create a property in the custom resource for each setter method in the JavaBean class.
For example, if the JavaBean class has a method named setAccount, specify a property named account and give it a value.
Make sure the JavaBean class is accessible to the GlassFish Server.
For example, you can place the JavaBean class in the as-install/lib directory.
To create a custom resource that provides properties to applications, set the custom resource's factory class to org.glassfish.resources.custom.factory.PropertiesFactory, then specify one or both of the following:
Create a property in the custom resource named fileName and specify as its value the path to a properties file or an XML file.
The path can be absolute or relative to as-install. The file must be accessible to the GlassFish Server.
If an XML file is specified, it must match the document type definition (DTD) specified in the API definition of java.util.Properties.
Create the desired properties directly as properties of the custom resource.
If both the fileName property and other properties are specified, the resulting property set is the union. If the same property is defined in the file and directly in the custom resource, the value of the latter takes precedence.
To create a custom resource that provides Java primitives to applications, follow these steps:
Set the custom resource's factory class to org.glassfish.resources.custom.factory.PrimitivesAndStringFactory.
Set the custom resource's resource type to one of the following or its fully qualified wrapper class name equivalent:
int
integer
long
double
float
char
character
short
byte
boolean
String
Create a property in the custom resource named value and give it the value needed by the application.
For example, If the application requires a double of value 22.1, create a property with the name value and the value 22.1.
To create a custom resource that provides URL instances to applications, follow these steps:
Set the custom resource's factory class to org.glassfish.resources.custom.factory.URLFactory.
Choose which of the following constructors to use:
URL(protocol, host, port, file)
URL(protocol, host, file)
URL(spec)
Define properties according to the chosen constructor.
For example, for the first constructor, define properties named protocol, host, port, and file. Example values might be http, localhost, 8085, and index.html, respectively.
For the third constructor, define a property named spec and assign it the value of the entire URL.