The Big Picture lesson discussed that a service provider typically contains several components. A service provider is delivered most commonly by packaging all of its components into a JAR file. This JAR should contain the class files of the different components and the JNDI resource files. The resource files allow programs to use the service provider with minimal configuration.
Here are the contents of the JAR for a typical sample service provider.This sample provider is in the package tut. It contains a context implementation (tut.SampleContextImpl and its inner classes) and an initial context factory (tut.SampleInitialContextFactory). It uses several object, state, and response control factories, some of which are included in the provider's resource file, tut/jndiprovider.properties. This file's contents of the are as follows:tut/SampleContextImpl.class tut/SampleContextImpl$Parser.class tut/SampleContextImpl$ListEnum.class tut/SampleContextImpl$BindingEnum.class tut/SampleContextImpl$SearchEnum.class tut/SampleInitialContextFactory.class tut/OneObjectFactory.class tut/TwoObjectFactory.class tut/ThreeObjectFactory.class tut/OneStateFactory.class tut/TwoStateFactory.class tut/SampleResponseControlFactory.class tut/OneResponseControl.class tut/TwoResponseControl.class tut/ThreeResponseControl.class tut/SampleObjectFactory.class tut/sam/samURLContextFactory.class tut/sam/samURLContext.class tut/jndiprovider.properties jndi.propertiesIncluding this file makes the listed factories visible only to this context implementation, as described in the Environment Properties lesson. The two object factories, tut.OneObjectFactory and tut.TwoObjectFactory, are not included in the jndiprovider.properties file because they are always referenced by their class names. (In other words, any reference that uses one of these factories will have its class name in getFactoryClassName().)java.naming.factory.object=tut.ThreeObjectFactory java.naming.factory.state=tut.OneStateFactory:tut.TwoStateFactory java.naming.factory.control=tut.SampleResponseControlFactory
The provider also contains an object factory for the context implementation itself, called tut.SampleObjectFactory. This class is responsible for creating an instance of tut.SampleContextImpl, when given a reference for it.
The provider supports the sam URL scheme and provides the corresponding URL context factory and implementation classes tut.sam.samURLContextFactory and tut.sam.samURLContext. The JAR contains a jndi.properties file that names the package prefix of the sam URL context factory. This allows the URL context factory to be considered automatically when the JNDI is looking for URL context factories. The contents of the jndi.properties file are as follows:This file also includes a setting for the initial context factory. This will cause any program that uses this JAR to use, by default, tut.SampleInitialContextFactory as the initial context factory.java.naming.factory.initial=tut.SampleInitialContextFactory java.naming.factory.url.pkgs=tut