FileDocCategorySizeDatePackage
EjbModuleDeployer.javaAPI DocGlassfish v2 API8685Fri May 04 22:34:32 BST 2007com.sun.enterprise.deployment.backend

EjbModuleDeployer

public class EjbModuleDeployer extends ModuleDeployer
EjbModuleDeployer is a class for deploying EJB Modules Much of the code is in the super-class.
author
bnevins
version

Fields Summary
DDGenerator
ddGenerator
private com.sun.enterprise.instance.EjbModulesManager
manager
private static com.sun.enterprise.util.i18n.StringManager
localStrings
Constructors Summary
EjbModuleDeployer(DeploymentRequest r)

		super(r);
    
Methods Summary
protected com.sun.enterprise.instance.BaseManagercreateConfigManager(com.sun.enterprise.instance.InstanceEnvironment ienv, com.sun.enterprise.instance.ModuleEnvironment menv)

		manager = new EjbModulesManager(ienv);
		return manager;
    
protected voiddeploy()

		loadDescriptors();
		runVerifier();
                // Set the generated XML directory in application desc
                request.getDescriptor().setGeneratedXMLDirectory(xmlDir.getAbsolutePath());
		ZipItem[] clientStubs = runEJBC();
		createClientJar(clientStubs);
    
protected voidgeneratePolicy()

		// if this is a part of application then generatePolicy in AppDeployerBa
		// se will be called, so this should be a no-op
		try
		{
			if(request.isApplication())
			{
				return;
			}
			else
			{
				Application app = request.getDescriptor();
				EjbBundleDescriptor ejbBundleDesc =
					(EjbBundleDescriptor)
					app.getStandaloneBundleDescriptor();
				//For standalone ejbs, the RoleMapper should be constructed by now
				String name = EJBSecurityManager.getContextID(ejbBundleDesc);
				SecurityUtil.generatePolicyFile(name);
                                EJBSecurityManagerFactory ejbsmf =
                                    (EJBSecurityManagerFactory)EJBSecurityManagerFactory.getInstance(); 
                                ejbsmf.createSecurityManager(
                                    (EjbDescriptor)ejbBundleDesc.getEjbs().iterator().next());
			}
		} 
		catch (IASSecurityException se)
		{
			String msg =
			localStrings.getString("enterprise.deployment.backend.generate_policy_error" );

			logger.log(Level.WARNING, msg, se);
			throw new IASDeploymentException(msg, se);
		}
    
protected booleanneedsStubs()

		return true;
    
protected voidpreDeploy()

		assert stubsDir   != null;
		assert moduleDir  != null;
		assert moduleName != null;

		try
		{
			if(request.isArchive()) {
                            // check if this is a .jar file or a single .class file
                            if (request.getFileSource().getFile().getName().endsWith(".class")) {
                                copyAutodeployedClassFile(request.getFileSource().getFile(), moduleDir);
                            } else {
        			J2EEModuleExploder.explodeJar(request.getFileSource().getFile(), moduleDir);                                
                            }
                        }

                        xmlDir.mkdirs();
                        stubsDir.mkdirs();
		}
		catch(Exception e)
		{
			throw new IASDeploymentException(e.toString(), e);
		}
    
protected voidregister()

		super.register();
		setShared(request.isSharedModule());
    
public voidremovePolicy()


	///////////////////////////////////////////////////////////////////////////
	
	    
	
		if (request.isApplication()) 
		{
			return;
		}

		String requestName = request.getName();
                EJBSecurityManagerFactory ejbsmf =
                   (EJBSecurityManagerFactory)EJBSecurityManagerFactory.getInstance(); 
                String[] names =
                    ejbsmf.getAndRemoveContextIdForEjbAppName(requestName);
                String name = null;
		try 
		{
                        if (names != null && names.length > 0 &&
                                names[0] != null) {
                            name = names[0];
                            SecurityUtil.removePolicy(name);
                            ejbsmf.removeSecurityManager(name);
                        }
		} 
		catch(IASSecurityException ex) 
		{
			String msg = localStrings.getString(
				"enterprise.deployment.backend.remove_policy_error",name);
			logger.log(Level.WARNING, msg, ex);
			throw new IASDeploymentException(msg, ex);
		}