FileDocCategorySizeDatePackage
EJBBundleInfoHelper.javaAPI DocGlassfish v2 API8568Fri May 04 22:34:48 BST 2007com.sun.jdo.spi.persistence.support.ejb.ejbc

EJBBundleInfoHelper

public class EJBBundleInfoHelper extends Object implements EJBInfoHelper
This is a class which implements the EJBInfoHelper interface based on EjbBundleDescriptor and other DOL classes.
author
Rochelle Raccah

Fields Summary
private static final char
UNDERLINE
private static final char
DOT
private final EjbBundleDescriptor
bundleDescriptor
private Collection
availableSchemaNames
private NameMapper
nameMapper
private com.sun.jdo.api.persistence.model.Model
model
Constructors Summary
public EJBBundleInfoHelper(EjbBundleDescriptor bundleDescriptor, Collection availableSchemaNames)
Creates a new instance of EJBBundleInfoHelper

param
bundleDescriptor the EjbBundleDescriptor which defines the universe of names for this application.
param
availableSchemaNames a Collection of available schemas in the application - used only during development


	                                    	 
	   
			  
		this(bundleDescriptor, null, null, availableSchemaNames);
	
EJBBundleInfoHelper(EjbBundleDescriptor bundleDescriptor, NameMapper nameMapper, com.sun.jdo.api.persistence.model.Model model, Collection availableSchemaNames)
Creates a new instance of EJBBundleInfoHelper

param
bundleDescriptor the EjbBundleDescriptor which defines the universe of names for this application.
param
nameMapper the NameMapper object to be used - allows a client to supply its own mapper to the helper rather than have the helper construct a new instance
param
model the Model object to be used - allows a client to supply its own mapper to the helper rather than have the helper construct a new instance
param
availableSchemaNames a Collection of available schemas in the application - used only during development

		this.bundleDescriptor = bundleDescriptor;
		this.nameMapper = nameMapper;
		this.model = model;
		this.availableSchemaNames = availableSchemaNames;
	
Methods Summary
public ConversionHelpercreateConversionHelper()

see
EJBInfoHelper#createConversionHelper

		return new EjbConversionHelper(getNameMapperInternal());
	
public AbstractNameMappercreateUniqueNameMapper()

see
EJBInfoHelper#createUniqueNameMapper

		return new NameMapper(bundleDescriptor);
	
public java.util.CollectiongetAvailableSchemaNames()
Gets a collection of names of schemas defined in this ejb jar. This implementation simply returns the list passed in the constructor or null if there was none supplied.

return
a collection schema names

		return availableSchemaNames;
	
private EjbBundleDescriptorgetBundleDescriptor()
Gets the EjbBundleDescriptor which defines the universe of names for this application.

return
the EjbBundleDescriptor which defines the universe of names for this application.

		return bundleDescriptor;
	
public java.lang.ClassLoadergetClassLoader()
Gets the class loader which corresponds to this ejb bundle.

return
the class loader which corresponds to this ejb bundle

		return bundleDescriptor.getClassLoader();
	
public java.lang.StringgetEjbJarDisplayName()

see
EJBInfoHelper#getEjbJarDisplayName

		return bundleDescriptor.getName();
	
public java.util.CollectiongetEjbNames()

see
EJBInfoHelper#getEjbNames

		Iterator iterator = getBundleDescriptor().getEjbs().iterator();
		ArrayList returnList = new ArrayList();

		while (iterator.hasNext()) {
			EjbDescriptor ejb = (EjbDescriptor)iterator.next();

            if (ejb instanceof EjbCMPEntityDescriptor)
				returnList.add(ejb.getName());
		}
		
		return returnList;
	
public java.util.CollectiongetFieldsForEjb(java.lang.String ejbName)

see
EJBInfoHelper#getFieldsForEjb

		Iterator iterator = getModel().getFields(ejbName).iterator();
		ArrayList returnList = new ArrayList();

		while (iterator.hasNext())
			returnList.add(iterator.next());

		return returnList;
	
public com.sun.jdo.api.persistence.model.ModelgetModel()

see
EJBInfoHelper#getModel

		if (model == null) {
			model = new DeploymentDescriptorModel(getNameMapperInternal(), 
				getClassLoader());
		}

		return model;
	
public AbstractNameMappergetNameMapper()

see
EJBInfoHelper#getNameMapper

		return getNameMapperInternal();
	
private NameMappergetNameMapperInternal()

		if (nameMapper == null)
			nameMapper = new NameMapper(bundleDescriptor, false);

		return nameMapper;
	
public java.util.CollectiongetRelationshipsForEjb(java.lang.String ejbName)

see
EJBInfoHelper#getRelationshipsForEjb

		Iterator iterator = getBundleDescriptor().getRelationships().iterator();
		ArrayList returnList = new ArrayList();

		// TODO: issue of usage of this - several iterations of this if
		// iterating all the bean - but, I think it can change, so can't 
		// cache it in a map (same comment applies to getEjbNames and 
		// getFieldsForEjb)
		while (iterator.hasNext()) {
			RelationshipDescriptor relD = 
				(RelationshipDescriptor)iterator.next();
			RelationRoleDescriptor testRole = relD.getSource();
			String cmrField = null;

			if (ejbName.equals(testRole.getOwner().getName())) {
				cmrField = testRole.getCMRField();
				if (cmrField != null)
					returnList.add(cmrField);
			}

			testRole = relD.getSink();
			if (ejbName.equals(testRole.getOwner().getName())) {
				cmrField = testRole.getCMRField();
				if (cmrField != null)
					returnList.add(cmrField);
			}
		}

		return returnList;
	
public org.netbeans.modules.dbschema.SchemaElementgetSchema(java.lang.String schemaName)
Gets the schema with the specified name, loading it if necessary. This implementation uses the class loader as the extra context information used to load.

param
schemaName the name of the schema to be loaded
return
the schema object

		return SchemaElement.forName(schemaName, getClassLoader());
	
public java.lang.StringgetSchemaNameToGenerate()
Gets the name to use for schema generation. This implementation uses a combo of app name, module name, etc.

return
the name to use for schema generation

		// make sure there is no '.' in schema name
		return DeploymentHelper.getDDLNamePrefix(
			getBundleDescriptor()).replace(DOT, UNDERLINE);