org.netbeans.modules.j2ee.deployment.plugins.api
Class ConfigurationSupport

java.lang.Object
  extended by org.netbeans.modules.j2ee.deployment.plugins.api.ConfigurationSupport

public abstract class ConfigurationSupport
extends Object

ConfigurationSupport provides support for server specific configuration. It supplements the JSR-88 DeploymentConfiguration class of life cycle management and some additional module change notifications.

The life cycle of the DeploymentConfiguration object.

When a new project is created or an existing one is opened, the j2eeserver will create a DeploymentConfiguration object for the project target server by calling DeploymentManager.createConfiguration(). After the configuration is created, the j2eeserver will initialize it by calling ConfigurationSupport.initConfiguration(). In this moment, plugin should make sure that the server specific deployment descriptors exist and create them, if they do not. From now on the server specific deployment descriptors for the target server should be ready to respond to the module changes.

In case that the project target server is changed, the old server is notified by calling ConfigurationSupport.disposeConfiguration() that the old DeploymentConfiguration will be disposed, which means that the j2eeserver will release the reference to it and the configuration will be no longer receiving notifications of the module changes. The server specific deployment descriptors for the old server will thus stop responding to the module changes.

The life cycle for the new target server is the same as if an existing project is opened, see above.

In case that the target server plugin needs to have access to the initilized deployment configuration before the j2eeserver created and initilized it by itself, the plugin can request the j2eeserver to create and initilize it by calling ConfigurationSupport.requestCreateConfiguration(). This may happen for example when the IDE is started and if the server specific deployment descriptor was left open in the editor before the IDE was shutdown the last time. After calling ConfigurationSupport.requestCreateConfiguration() the life cycle is the same as if the j2eeserver created and initialized the deployment configuration during project opening by itself.

In case that other than target server plugin needs to have access to the initilized deployment configuration, the plugin can request the j2eeserver to create and initilize the configuration by calling ConfigurationSupport.requestCreateConfiguration(). The j2eeserver will create the configuration by calling DeploymentManager.createConfiguration() and will initilize it by calling ConfigurationSupport.initConfiguration(), however, with the keepUpdated=false parameter. This will tell the plugin that its server specific deployment descriptors should not respond to the module changes. In fact, the deployment configuration will not be receiving module change events in this case. Since the j2eeserver will not even keep a reference to this configuration, the ConfigurationSupport.disposeConfiguration() will never be called for this configuration, there is also no reason for it.

Since:
1.8

Constructor Summary
ConfigurationSupport()
           
 
Method Summary
 Datasource createDatasource(javax.enterprise.deploy.spi.DeploymentConfiguration config, String jndiName, String url, String username, String password, String driver)
          Creates and saves data source in the module if it does not exist yet in the module.
abstract  void disposeConfiguration(javax.enterprise.deploy.spi.DeploymentConfiguration config)
          The specified deployment configuration instance is about to be disposed, which means that the j2eeserver will release the reference to it and the configuration will be no longer receiving notifications of the module changes.
abstract  void ensureResourceDefined(javax.enterprise.deploy.spi.DeploymentConfiguration config, javax.enterprise.deploy.model.DDBean bean)
          Ensure resource is defined for the specified DD bean (for example entity bean).
 Set<Datasource> getDatasources(javax.enterprise.deploy.spi.DeploymentConfiguration config)
          Gets the data sources saved in the module.
abstract  String getWebContextRoot(javax.enterprise.deploy.spi.DeploymentConfiguration config, javax.enterprise.deploy.model.DeployableObject deplObj)
          Return the context root (context path) defined for the module specified by the deployable object.
abstract  void initConfiguration(javax.enterprise.deploy.spi.DeploymentConfiguration config, File[] files, File resourceDir, boolean keepUpdated)
          Initialize the specified deployment configuration.
 boolean isDatasourceCreationSupported()
          Tests whether data source creation is supported.
static void requestCreateConfiguration(org.openide.filesystems.FileObject fo, String serverID)
           Request the j2eeserver to create and initialize the deployment configuration for the specified server and module the given server specific deployment descriptor file belongs to.
abstract  void setMappingInfo(javax.enterprise.deploy.spi.DeploymentConfiguration config, OriginalCMPMapping[] mappings)
          Setting the CMP and CMR mapping info to the given configuration for the EJB by the given name.
abstract  void setWebContextRoot(javax.enterprise.deploy.spi.DeploymentConfiguration config, javax.enterprise.deploy.model.DeployableObject deplObj, String contextRoot)
          Set the web context root (context path) for the module specified by the deployable object.
abstract  void updateResourceDir(javax.enterprise.deploy.spi.DeploymentConfiguration config, File resourceDir)
          Update the enterprise resource directory for the specified deployment configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationSupport

public ConfigurationSupport()
Method Detail

setMappingInfo

public abstract void setMappingInfo(javax.enterprise.deploy.spi.DeploymentConfiguration config,
                                    OriginalCMPMapping[] mappings)
Setting the CMP and CMR mapping info to the given configuration for the EJB by the given name. This call will be called after CMP wizard created all CMP beans (all new ejb events fired).

Parameters:
config - The configuration to push the CMP mapping to
mappings - All the mapping info needed to be pushed in one batch.

ensureResourceDefined

public abstract void ensureResourceDefined(javax.enterprise.deploy.spi.DeploymentConfiguration config,
                                           javax.enterprise.deploy.model.DDBean bean)
Ensure resource is defined for the specified DD bean (for example entity bean).

Parameters:
config - deployment configuration
bean - DD bean in question

getWebContextRoot

public abstract String getWebContextRoot(javax.enterprise.deploy.spi.DeploymentConfiguration config,
                                         javax.enterprise.deploy.model.DeployableObject deplObj)
                                  throws javax.enterprise.deploy.spi.exceptions.ConfigurationException
Return the context root (context path) defined for the module specified by the deployable object.

Parameters:
config - deployment configuration
deplObj - deployable object that specifies the module
Returns:
context root
Throws:
javax.enterprise.deploy.spi.exceptions.ConfigurationException - reports errors in getting the web context root

setWebContextRoot

public abstract void setWebContextRoot(javax.enterprise.deploy.spi.DeploymentConfiguration config,
                                       javax.enterprise.deploy.model.DeployableObject deplObj,
                                       String contextRoot)
                                throws javax.enterprise.deploy.spi.exceptions.ConfigurationException
Set the web context root (context path) for the module specified by the deployable object.

Parameters:
config - deployment configuration
deplObj - deployable object that specifies the module
contextRoot - context root to be set
Throws:
javax.enterprise.deploy.spi.exceptions.ConfigurationException - reports errors in setting the web context root

initConfiguration

public abstract void initConfiguration(javax.enterprise.deploy.spi.DeploymentConfiguration config,
                                       File[] files,
                                       File resourceDir,
                                       boolean keepUpdated)
                                throws javax.enterprise.deploy.spi.exceptions.ConfigurationException
Initialize the specified deployment configuration. If keepUpdated is true ensure the server specific deployment descriptors are created if they do not exist and that they are ready to respond to the module changes. If keepUpdated is false, the module changes should not be reflected in the server specific deployment descriptors.

Parameters:
config - the deployment configuration that should be initialized.
files - server specific deployment configuration files.
resourceDir - directory containing definition for enterprise resources needed for the module execution or null if not supported.
ensureCreated - if keepUpdated is true ensure the server specific deployment descriptors are created if they do not exist and that they are ready to respond to the module changes. If keepUpdated is false, the module changes should not be reflected in the server specific deployment descriptors.
Throws:
javax.enterprise.deploy.spi.exceptions.ConfigurationException - reports errors in deployment configuration initialization.

disposeConfiguration

public abstract void disposeConfiguration(javax.enterprise.deploy.spi.DeploymentConfiguration config)
The specified deployment configuration instance is about to be disposed, which means that the j2eeserver will release the reference to it and the configuration will be no longer receiving notifications of the module changes.

Parameters:
config - deployment configuration which is about to be disposed.

requestCreateConfiguration

public static final void requestCreateConfiguration(org.openide.filesystems.FileObject fo,
                                                    String serverID)
                                             throws javax.enterprise.deploy.spi.exceptions.ConfigurationException

Request the j2eeserver to create and initialize the deployment configuration for the specified server and module the given server specific deployment descriptor file belongs to. If the deployment configuration has already been created nothing will happen, otherwise a new instance will be created by calling DeploymentManager.createConfiguration() and then initialized by calling ConfigurationSupport.initConfiguration().

The j2eeserver creates and initializes the deployment configuration for the server that is set as a target server for the given module. In some cases, however, the data object representing the server specific deployment descriptor may require access to the initialized deployment configuration even before the configuration is created and initialized by the j2eeserver itself. This may happen for instance when the server specific deployment descriptor is being reopened during the IDE startup if it was left open before the IDE was shut down the last time.

Parameters:
fo - server specific deployment descriptor file object
serverID - server (plugin) ID
Throws:
javax.enterprise.deploy.spi.exceptions.ConfigurationException

updateResourceDir

public abstract void updateResourceDir(javax.enterprise.deploy.spi.DeploymentConfiguration config,
                                       File resourceDir)
Update the enterprise resource directory for the specified deployment configuration.

Parameters:
config - deployment configuration
resourceDir - new enterprise resource directory.
Since:
1.12

getDatasources

public Set<Datasource> getDatasources(javax.enterprise.deploy.spi.DeploymentConfiguration config)
Gets the data sources saved in the module.

Parameters:
config - deployment configuration
Returns:
a set of data sources. The default implementation returns an empty set.
Since:
1.15

isDatasourceCreationSupported

public boolean isDatasourceCreationSupported()
Tests whether data source creation is supported.

Returns:
true if data source creation is supported. The default implementation returns false.
Since:
1.15

createDatasource

public Datasource createDatasource(javax.enterprise.deploy.spi.DeploymentConfiguration config,
                                   String jndiName,
                                   String url,
                                   String username,
                                   String password,
                                   String driver)
                            throws javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException,
                                   javax.enterprise.deploy.spi.exceptions.ConfigurationException,
                                   DatasourceAlreadyExistsException
Creates and saves data source in the module if it does not exist yet in the module. Data source is considered to be existing when JNDI name of the found data source and the one just created equal.

Parameters:
config - deployment configuration
jndiName - name of data source
url - database URL
username - database user
password - user's password
driver - fully qualified name of the database driver class
Returns:
created data source
Throws:
javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException - if operation is not supported
javax.enterprise.deploy.spi.exceptions.ConfigurationException - if data source configuration file is not parseable
DatasourceAlreadyExistsException - if conflicting data source is found
Since:
1.15

 

Built on March 27 2006.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.