KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > backend > DeploymentRequest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * DeploymentRequest.java
26  *
27  * Created on December 10, 2001, 11:29 PM
28  */

29
30 package com.sun.enterprise.deployment.backend;
31 import com.sun.enterprise.loader.EJBClassLoader;
32 import java.io.*;
33 import java.util.List JavaDoc;
34 import java.util.Map JavaDoc;
35 import java.util.Properties JavaDoc;
36 import javax.enterprise.deploy.spi.Target JavaDoc;
37 import com.sun.enterprise.util.io.*;
38 import com.sun.enterprise.util.StringUtils;
39 import com.sun.enterprise.instance.InstanceEnvironment;
40 import com.sun.enterprise.instance.ApplicationEnvironment;
41 import com.sun.enterprise.instance.ModuleEnvironment;
42 import com.sun.enterprise.deployment.Application;
43 import com.sun.enterprise.util.diagnostics.ObjectAnalyzer;
44 import com.sun.enterprise.instance.AppsManager;
45 import com.sun.enterprise.util.i18n.StringManager;
46 import com.sun.enterprise.server.Constants;
47 import com.sun.enterprise.management.deploy.DeploymentCallback;
48
49 /**
50  *
51  * @author bnevins
52  * @version
53  */

54
55 public class DeploymentRequest
56 {
57     private boolean isDone = false;
58     
59     ///////////////////////////////////////////////////////////////////////////
60
///////// Public Methods ///////////////////////////////////////////
61
///////////////////////////////////////////////////////////////////////////
62

63     /** Create a deployment request object. The constructor must be called with the three
64      * arguments required for all deployment requests. You must call other methods
65      * to set attributes required for <i>some</i> requests.
66      * @parameter iEnv InstanceEnvironment object
67      * @parameter theCommand The command (Deploy Redeploy Undeploy) of the request
68      * @parameter theType The type of deployment (Application, Web Module, EJB Module, Connector Module
69      */

70     public DeploymentRequest(
71         InstanceEnvironment iEnv,
72         DeployableObjectType theType,
73         DeploymentCommand theCommand)
74         //File source, // directory or archive here - optional for undeploy
75
//String theName)
76
throws IASDeploymentException
77     {
78         // order counts -- don't change it unless you know what you're doing!
79
instanceEnv = iEnv;
80         setType(theType);
81         setCommand(theCommand);
82     }
83     
84     ///////////////////////////////////////////////////////////////////////////
85

86     /** Makes sure everything that needs to be setup is OK. Use it
87      * just before deploying
88      * WBN: 4-26-02 added code to change Deploy to Redeploy if neccessary
89      */

90     public void verify() throws IASDeploymentException
91     {
92         if(isVerified)
93             return;
94         
95         if(isFileSourceRequired() && fileSource == null) {
96             String JavaDoc msg = localStrings.getString(
97                     "enterprise.deployment.backend.file_source_required" );
98             throw new IASDeploymentException( msg );
99         }
100     
101         if(isNameRequired() && name == null) {
102             String JavaDoc msg = localStrings.getString(
103                     "enterprise.deployment.backend.name_required" );
104             throw new IASDeploymentException( msg );
105         }
106         
107         if(isContextRootRequired() && contextRoot == null &&
108                     defaultContextRoot == null) {
109
110             String JavaDoc msg = localStrings.getString(
111                     "enterprise.deployment.backend.context_root_required" );
112             throw new IASDeploymentException( msg );
113         }
114         
115         if(name == null) // this is true iff no name is required to be supplied
116
createName();
117         
118         // Bug 4679970 -- we must have a file-system-legal name.
119
// we have a contract with other code that there will be a client jar
120
// whose name is <app-name>Client.jar
121
// thus AppName: "foo?<*//x" --> "foo?<*//xClient.jar" -- impossible to create!!
122

123         if(!FileUtils.isLegalFilename(name))
124         {
125             // 2 approaches -- (1) don't allow it and (2) change the name
126
// We're going with approach (1) for now...
127

128             // approach (1)
129
String JavaDoc msg = localStrings.getString(
130                 "enterprise.deployment.backend.illegal_characters_in_component_name",
131                 FileUtils.getIllegalFilenameCharacters() );
132             throw new IASDeploymentException( msg );
133             // approach (2)
134
//name = FileUtils.makeLegalFilename(name);
135
}
136     
137         setEnv();
138         checkForRedeploy();
139         isVerified = true;
140     }
141     
142     /** sets the Name of the App or Module. If you don't call this, and if it's legal,
143      * one will be provided for you at no cost.
144      * <br>Deploy - not required
145      * <br>Redeploy - required
146      * <br>Undeploy - required
147      * @param theName String name of module or application
148      */

149     public void setName(String JavaDoc theName) throws IASDeploymentException
150     {
151         if(StringUtils.ok(theName))
152             name = theName;
153
154         else if(isNameRequired()) {
155             String JavaDoc msg = localStrings.getString(
156                     "enterprise.deployment.backend.null_setname" );
157             throw new IASDeploymentException( msg );
158         }
159     }
160
161     /** Sets the source of deployment files.
162      * <br>Deploy - required
163      * <br>Redeploy - required
164      * <br>Undeploy - not required
165      * @param src String pointing at Archive file or root-dir for user-specified
166      * 'pre-exploded' deployment
167      */

168     public void setFileSource(String JavaDoc src) throws IASDeploymentException
169     {
170         setFileSource(new File(src));
171     }
172     
173     /** Sets the source of deployment files.
174      * <br>Deploy - required
175      * <br>Redeploy - required
176      * <br>Undeploy - not required
177      * @param src File Object pointing at Archive file or root-dir for user-specified
178      * 'pre-exploded' deployment
179      */

180     public void setFileSource(File src) throws IASDeploymentException
181     {
182         fileSource = null;
183         
184         if(src == null && !isFileSourceRequired())
185             return; // all OK...
186

187         try
188         {
189             fileSource = new FileSource(src);
190         }
191         catch(Exception JavaDoc e)
192         {
193             if(isFileSourceRequired())
194                 throw new IASDeploymentException("DeploymentRequest.setFileSource()" + e);
195         }
196     }
197
198
199          public void setDeploymentPlan(File plan) {
200              deploymentPlan = plan;
201          }
202
203          public File getDeploymentPlan() {
204              return deploymentPlan;
205          }
206
207          public void setDeploymentCallback(DeploymentCallback callback) {
208              deploymentCallback = callback;
209          }
210
211          public DeploymentCallback getDeploymentCallback() {
212              return deploymentCallback;
213          }
214
215          public void setAbort(boolean isAborted) {
216              this.isAborted = isAborted;
217          }
218
219          public boolean isAborted() {
220              return isAborted;
221          }
222
223          public void setReload(boolean isReload) {
224              this.isReload = isReload;
225          }
226
227          public boolean isReload() {
228              return isReload;
229          }
230
231          public void setTargetName(String JavaDoc name)
232          {
233              targetName = name;
234          }
235
236          public String JavaDoc getTargetName()
237          {
238              return targetName;
239          }
240
241     ///////////////////////////////////////////////////////////////////////////
242

243     /** sets the 'shared' attribute
244      * @param shared true for shared Ejb modules, false for unshared Ejb modules
245      */

246     public void setShared(boolean newShared) throws IASDeploymentException
247     {
248         if(!isEjbModule()) {
249             String JavaDoc msg = localStrings.getString(
250                     "enterprise.deployment.backend.cannot_set_shared_flag" );
251             throw new IASDeploymentException( msg );
252         }
253             
254         shared = newShared;
255     }
256     /** sets the 'forced' attribute. If set to true - no error occurs if the App or Module is
257      * already registered. If false, an Exception will be thrown if the App or Module is already
258      * deployed.
259      * @param newForced true for forcing Deployment of already registered Apps/Modules.
260      * I.e. a Redeployment
261      */

262     public void setForced(boolean newForced)
263     {
264         forced = newForced;
265     }
266     /**
267     * Adds the optional arguments for this request. Currently - these are CMP-only args.
268     * It would have been nice to add these args to the pre-existing
269     * optionalAttributes. But those attributes are all blindly added to Config by
270     * classes in the instance package. It would have been a KLUDGE-fest to separate
271     * the different name-value pairs in this class and then repackage. Which is why
272     * we have yet-another Properties object.
273     * bnevins 4/3/2003
274     */

275     public void addOptionalArguments(Properties JavaDoc props)
276     {
277         /* We want to be slightly smart here. If this method is called more than once,
278         * we can't just wipe-out the earlier mappings!
279         * So we keep our own Properties object and always ADD to it...
280         * If this method is never called, optionalArguments will be empty but not null.
281         */

282             optionalArguments.putAll(props);
283         }
284
285         public void addOptionalArguments(Map JavaDoc map)
286         {
287             optionalArguments.putAll(map);
288         }
289
290     /**
291     * Adds one optional argument.
292     * @see addOptionalArguments
293     */

294     public void addOptionalArgument(String JavaDoc key, String JavaDoc value)
295     {
296         optionalArguments.put(key, value);
297     }
298
299      ///////////////////////////////////////////////////////////////////////////
300

301     /**
302      * sets the 'precompile-jsp' attribute. If set to true - JSP precompilation is
303      * performed, if neccessary. If the precompile has errors, the deployment will
304      * officially fail. This feature is by default, false.
305      * @param precompileJSP true for performing JSP compilation at Deployment Time.
306      */

307     public void setPrecompileJSP(boolean newPrecompileJSP)
308     {
309         precompileJSP = newPrecompileJSP;
310     }
311
312     /**
313      * @returns whether or not precompiling JSP is enabled -- the default is false.
314      */

315     public boolean getPrecompileJSP()
316     {
317         return precompileJSP;
318     }
319
320         /**
321          * sets the 'generate-rmi-stubs' attribute.
322          * @param newGenerateRMIStubs
323          */

324         public void setGenerateRMIStubs(boolean newGenerateRMIStubs)
325         {
326                 generateRMIStubs = newGenerateRMIStubs;
327         }
328          
329         /**
330          * @returns the 'generate-rmi-stubs' attribute.
331          */

332         public boolean getGenerateRMIStubs()
333         {
334                 return generateRMIStubs;
335         }
336
337        /**
338          * sets the 'availability-enabled' attribute.
339          * @param newAvailabilityEnabled
340          */

341         public void setAvailabilityEnabled(boolean newAvailabilityEnabled)
342         {
343                 availabilityEnabled = newAvailabilityEnabled;
344         }
345         
346         /**
347          * @returns the 'availability-enabled' attribute.
348          */

349         public boolean isAvailabilityEnabled()
350         {
351                 return availabilityEnabled;
352         }
353
354        /**
355          * sets the 'java-web-start-enabled' attribute.
356          * @param newJavaWebStartEnabled
357          */

358         public void setJavaWebStartEnabled(boolean newJavaWebStartEnabled)
359         {
360                 javaWebStartEnabled = newJavaWebStartEnabled;
361         }
362          
363         /**
364          * @returns the 'java-web-start-enabled' attribute.
365          */

366         public boolean isJavaWebStartEnabled()
367         {
368                 return javaWebStartEnabled;
369         }
370
371        /**
372          * sets the 'libraries' attribute.
373          * @param newLibraries
374          */

375         public void setLibraries(String JavaDoc newLibraries)
376         {
377                 libraries = newLibraries;
378         }
379
380         /**
381          * @returns the 'libraries' attribute.
382          */

383         public String JavaDoc getLibraries()
384         {
385                 return libraries;
386         }
387
388         /**
389          * @returns the 'resourceAction' attribute.
390          */

391         public String JavaDoc getResourceAction()
392         {
393                 return resourceAction;
394         }
395
396         /**
397          * sets the 'resourceAction' attribute.
398          * @param newResourcesAction
399          */

400         public void setResourceAction (String JavaDoc newResourceAction)
401         {
402                 resourceAction = newResourceAction;
403         }
404
405         /**
406          * sets the 'targetList' attribute.
407          * @param newTargetList
408          */

409         public void setResourceTargetList (String JavaDoc newTargetList)
410         {
411                 resourceTargetList = newTargetList;
412         }
413
414         /**
415          * @returns the 'targetList' attribute.
416          */

417         public String JavaDoc getResourceTargetList()
418         {
419                 return resourceTargetList;
420         }
421
422     ///////////////////////////////////////////////////////////////////////////
423

424     /** gets the 'forced' attribute.
425      * @return forced attribute
426      */

427     public boolean isForced()
428     {
429         return forced;
430     }
431     
432     ///////////////////////////////////////////////////////////////////////////
433

434     public File getClientJar()
435     {
436         return clientJar;
437     }
438     
439     ///////////////////////////////////////////////////////////////////////////
440

441     public boolean isApplication()
442     {
443         return DeployableObjectType.APP.equals(type);
444     }
445
446     /** Set the Context Root for Web Modules
447      */

448     public void setContextRoot(String JavaDoc s)
449     {
450         contextRoot = s;
451     }
452     
453     ///////////////////////////////////////////////////////////////////////////
454

455     public String JavaDoc getContextRoot()
456     {
457         return contextRoot;
458     }
459     
460         /** Set the default Context Root for Web Modules
461          */

462         public void setDefaultContextRoot(String JavaDoc s)
463         {
464                 defaultContextRoot = s;
465         }
466
467         public String JavaDoc getDefaultContextRoot()
468         {
469                 return defaultContextRoot;
470         }
471
472
473     ///////////////////////////////////////////////////////////////////////////
474

475     public boolean isModule()
476     {
477         return isWebModule() || isEjbModule() || isConnectorModule() || isAppClientModule();
478     }
479     
480     ///////////////////////////////////////////////////////////////////////////
481

482     public boolean isSharedModule()
483     {
484         return isModule() && shared;
485     }
486     
487     ///////////////////////////////////////////////////////////////////////////
488

489     public boolean isStandAloneModule()
490     {
491         return isModule() && !shared;
492     }
493     
494     ///////////////////////////////////////////////////////////////////////////
495

496     public boolean isWebModule()
497     {
498         return DeployableObjectType.WEB.equals(type);
499     }
500     
501     ///////////////////////////////////////////////////////////////////////////
502

503     public boolean isEjbModule()
504     {
505         return DeployableObjectType.EJB.equals(type);
506     }
507     
508     ///////////////////////////////////////////////////////////////////////////
509

510     public boolean isConnectorModule()
511     {
512         return DeployableObjectType.CONN.equals(type);
513     }
514     
515     ///////////////////////////////////////////////////////////////////////////
516

517     public boolean isAppClientModule()
518     {
519         return DeployableObjectType.CAR.equals(type);
520     }
521     
522
523     ///////////////////////////////////////////////////////////////////////////
524

525     public boolean isDeploy() throws IASDeploymentException
526     {
527         if(command == null)
528         {
529             String JavaDoc msg =localStrings.getString( "enterprise.deployment.backend.no_command");
530             throw new IASDeploymentException( msg );
531         }
532         // setCommand, called from the ctor already verified command
533
// if this assert fires that means a programmer must have set the
534
// command back to null -- Programmer Error
535
//assert command != null;
536

537         // check for null again -- this might be a release build!
538
//if(command == null)
539
//return false;
540

541         return command.equals(DeploymentCommand.DEPLOY);
542     }
543     
544     ///////////////////////////////////////////////////////////////////////////
545

546     public boolean isReDeploy() throws IASDeploymentException
547     {
548         if(command == null)
549         {
550             String JavaDoc msg =localStrings.getString( "enterprise.deployment.backend.no_command");
551             throw new IASDeploymentException( msg );
552         }
553         
554         // setCommand, called from the ctor already verified command
555
// if this assert fires that means a programmer must have set the
556
// command back to null -- Programmer Error
557
//assert command != null;
558

559         // check for null again -- this might be a release build!
560
//if(command == null)
561
//return false;
562

563         return command.equals(DeploymentCommand.REDEPLOY);
564     }
565     
566     ///////////////////////////////////////////////////////////////////////////
567

568     public boolean isUnDeploy() throws IASDeploymentException
569     {
570         if(command == null)
571         {
572             String JavaDoc msg =localStrings.getString( "enterprise.deployment.backend.no_command");
573             throw new IASDeploymentException( msg );
574         }
575         
576         // setCommand, called from the ctor already verified command
577
// if this assert fires that means a programmer must have set the
578
// command back to null -- Programmer Error
579
//assert command != null;
580

581         // check for null again -- this might be a release build!
582
//if(command == null)
583
//return false;
584

585         return command.equals(DeploymentCommand.UNDEPLOY);
586     }
587     
588     ///////////////////////////////////////////////////////////////////////////
589

590     public boolean isArchive() throws IASDeploymentException
591     {
592         if(isUnDeploy()) {
593             String JavaDoc msg = localStrings.getString(
594                     "enterprise.deployment.backend.invalid_isarchive_call" );
595             throw new IASDeploymentException( msg );
596         }
597
598         return getFileSource().isArchive();
599     }
600     
601     ///////////////////////////////////////////////////////////////////////////
602

603     public boolean isDirectory() throws IASDeploymentException
604     {
605         if(isUnDeploy())
606             //throw new IASDeploymentException("Internal Error -- invalid to call isDirectory() for an Undeploy");
607
return false;
608         
609         return getFileSource().isDirectory();
610     }
611
612     ///////////////////////////////////////////////////////////////////////////
613

614     public String JavaDoc getName()
615     {
616         return name;
617     }
618
619     ///////////////////////////////////////////////////////////////////////////
620

621     public String JavaDoc toString()
622     {
623         return ObjectAnalyzer.toString(this);
624     }
625
626     ///////////////////////////////////////////////////////////////////////////
627

628     public void setDebug(boolean what)
629     {
630         debug = true;
631     }
632
633     ///////////////////////////////////////////////////////////////////////////
634

635     public boolean getDebug()
636     {
637         return debug;
638     }
639
640     ///////////////////////////////////////////////////////////////////////////
641

642     public void setNoEJBC()
643     {
644         noEJBC = true;
645     }
646
647     ///////////////////////////////////////////////////////////////////////////
648

649
650     public boolean getNoEJBC()
651     {
652         return noEJBC;
653     }
654
655     ///////////////////////////////////////////////////////////////////////////
656

657     /**
658      * Deployment backend runs verifier during deployment when set to true.
659      *
660      * @param what when true, deployment backend runs verifier
661      */

662     public void setVerifying(boolean what)
663     {
664         isVerifying = what;
665     }
666     /**
667      * Returns a boolean indicating whether this application is going
668      * to be verified during deployment.
669      *
670      * @return when true, deployment backedn runs verifier
671      */

672     public boolean isVerifying()
673     {
674         return isVerifying;
675     }
676     /**
677      * Return the App or Module Directory so that ownership can be modified, if neccessary.
678      * @return The full path root directory of the deployed directory
679      */

680     public File getDeployedDirectory()
681     {
682         if(!FileUtils.safeIsDirectory(deployedDirectory))
683             deployedDirectory = null;
684         
685         return deployedDirectory;
686     }
687     /**
688      * Return the Stubs Directory so that ownership can be modified, if neccessary.
689      * @return The full path stubs directory root.
690      */

691     public File getStubsDirectory()
692     {
693         if(!FileUtils.safeIsDirectory(stubsDirectory))
694             stubsDirectory = null;
695         
696         return stubsDirectory;
697     }
698     /**
699      * Return the Stubs Directory so that ownership can be modified, if neccessary.
700      * @return The full path stubs directory root.
701      */

702     public File getJSPDirectory()
703     {
704         if(!FileUtils.safeIsDirectory(jspDirectory))
705             jspDirectory = null;
706         
707         return jspDirectory;
708     }
709
710
711     /**
712      * Return the Directory where the modified xml files will be located.
713      * @return The full path generated xml directory root.
714      */

715     public File getGeneratedXMLDirectory()
716     {
717                 if(!FileUtils.safeIsDirectory(generatedXMLDirectory))
718                         generatedXMLDirectory = null;
719
720         return generatedXMLDirectory;
721     }
722
723     ///////////////////////////////////////////////////////////////////////////
724
///////// Package Methods ///////////////////////////////////////////
725
///////////////////////////////////////////////////////////////////////////
726

727     /* package */ void setClientJar(File f) //throws IASDeploymentException
728
{
729         /*
730         File p = f.getParentFile();
731         
732         if(!FileUtils.safeIsDirectory(f))
733             throw new IASDeploymentException("Illegal parameter to setClientJarFile(). " +
734                 "The file (" + FileUtils.safeGetCanonicalPath(f) + ") has no existing parent directory.");
735         */

736         clientJar = f;
737     }
738     
739     ///////////////////////////////////////////////////////////////////////////
740

741     public FileSource getFileSource()
742     {
743         return fileSource;
744     }
745     
746     ///////////////////////////////////////////////////////////////////////////
747

748     public DeployableObjectType getType()
749     {
750         return type;
751     }
752     
753     ///////////////////////////////////////////////////////////////////////////
754

755     /* package */ DeploymentCommand getCommand()
756     {
757         return command;
758     }
759     
760     ///////////////////////////////////////////////////////////////////////////
761
/**
762     String getInstanceName()
763     {
764         return instanceEnv.getName();
765     }
766 */

767     ///////////////////////////////////////////////////////////////////////////
768

769     public InstanceEnvironment getInstanceEnv()
770     {
771         return instanceEnv;
772     }
773     
774     ///////////////////////////////////////////////////////////////////////////
775

776     /* package */ ApplicationEnvironment getAppEnv() throws IASDeploymentException
777     {
778         if(!isApplication()) {
779             String JavaDoc msg = localStrings.getString(
780                 "enterprise.deployment.backend.illegal_getapplicationenv_call");
781             throw new IASDeploymentException( msg );
782         }
783         
784         return appEnv;
785     }
786     
787     ///////////////////////////////////////////////////////////////////////////
788

789     /* package */ ModuleEnvironment getModuleEnv() throws IASDeploymentException
790     {
791         if(!isModule()) {
792             String JavaDoc msg = localStrings.getString(
793                     "enterprise.deployment.backend.illegal_getmoduleenv_call");
794             throw new IASDeploymentException( msg );
795         }
796
797         return moduleEnv;
798     }
799
800     ///////////////////////////////////////////////////////////////////////////
801

802     /* package */ boolean isEar()
803     {
804         // check if it's archive deployment and
805
// if it's an application
806
return isApplication() && fileSource.isArchive();
807     }
808
809     ///////////////////////////////////////////////////////////////////////////
810

811     /* package */ boolean isWar()
812     {
813         // check if it's archive deployment and
814
// if it's a web module
815
return isWebModule() && fileSource.isArchive();
816     }
817     ///////////////////////////////////////////////////////////////////////////
818

819     /* package */ boolean isEjbJar()
820     {
821         // check if it's archive deployment and
822
// if it's a ejb module
823
return isEjbModule() && fileSource.isArchive();
824     }
825
826     /**
827      * Sets the parent class loader to be used for this request.
828      *
829      * @param cl parant class loader
830      */

831     void setParentClassLoader(ClassLoader JavaDoc cl)
832     {
833         this.parentClassLoader = cl;
834     }
835
836     /**
837      * Returns the parent class loader for this request.
838      *
839      * @return the parent class loader
840      */

841     ClassLoader JavaDoc getParentClassLoader()
842     {
843         return this.parentClassLoader;
844     }
845         
846     /**
847      * Sets the parent class paths for this request.
848      */

849     void setParentClasspath(List JavaDoc classpaths)
850     {
851         this.parentClasspath = classpaths;
852     }
853
854     /**
855      * Returns the parent class paths for this request.
856      *
857      * @return the parent class paths
858      */

859     List JavaDoc getParentClasspath()
860     {
861         return this.parentClasspath;
862     }
863         
864     /**
865      * Sets the optional attributes for this request.
866      */

867     public void setOptionalAttributes(Properties JavaDoc optionalAttributes)
868     {
869         this.optionalAttributes = optionalAttributes;
870     }
871
872     /**
873      * Returns the optional attributes for this request.
874      *
875      * @return Properties with the optional attributes
876      */

877     public Properties JavaDoc getOptionalAttributes()
878     {
879         return this.optionalAttributes;
880     }
881         
882
883     /**
884      * Sets the ejb class loader to be used for this request.
885      *
886      * @param cl ejb class loader
887      */

888     void setEjbClassLoader(ClassLoader JavaDoc cl)
889     {
890         this.ejbClassLoader = cl;
891     }
892
893     /**
894      * Returns the ejb class loader for this request.
895      *
896      * @return the ejb class loader
897      */

898     ClassLoader JavaDoc getEjbClassLoader()
899     {
900         return this.ejbClassLoader;
901     }
902         
903     /**
904      * Sets the complete class paths for this request.
905      */

906     void setCompleteClasspath(List JavaDoc classpaths)
907     {
908         this.completeClasspath = classpaths;
909     }
910
911     /**
912      * Returns the complete class paths for this request.
913      *
914      * @return the ejb class paths
915      */

916     List JavaDoc getCompleteClasspath()
917     {
918         return this.completeClasspath;
919     }
920     
921     /**
922      * Sets the module classpath (no env classpath) for this
923      * request
924      * @param the module classpath
925      */

926     void setModuleClasspath(List JavaDoc classpath) {
927     moduleClasspath = classpath;
928     }
929     
930     /**
931      * @return the module classpath for this request
932      */

933     List JavaDoc getModuleClasspath() {
934     
935     return moduleClasspath;
936     }
937
938     /**
939      * Returns the optional arguments for this request.
940      * It is guaranteed to be not-null, but might be empty.
941      * @return the optional arguments
942      */

943     public Properties JavaDoc getOptionalArguments()
944     {
945         return optionalArguments;
946     }
947
948     /**
949      * Set the App or Module Directory so that ownership can be modified, if neccessary.
950      */

951     public void setDeployedDirectory(File d)
952     {
953         deployedDirectory = d;
954     }
955     /**
956      * Set the Stubs Directory so that ownership can be modified, if neccessary.
957      */

958     public void setStubsDirectory(File d)
959     {
960         stubsDirectory = d;
961     }
962     /**
963      * Set the Stubs Directory so that ownership can be modified, if neccessary.
964      */

965     public void setJSPDirectory(File d)
966     {
967         jspDirectory = d;
968     }
969
970     /**
971      * Set the Directory where the modified xml files will be located
972      */

973     public void setGeneratedXMLDirectory(File d)
974     {
975         generatedXMLDirectory = d;
976     }
977
978
979     /** return false, if the variable is false. Any other case -- return true.
980      */

981     boolean isMaybeCMPDropTables()
982     {
983         String JavaDoc s = getOptionalArguments().getProperty(Constants.CMP_DROP_TABLES);
984         
985         if(s != null && s.equalsIgnoreCase(Constants.FALSE))
986             return false;
987         
988         return true;
989     }
990     
991     
992         public String JavaDoc getHttpHostName()
993         {
994             return httpHostName;
995         }
996         
997         public void setHttpHostName(String JavaDoc hostName)
998         {
999             httpHostName = hostName;
1000        }
1001        
1002        public int getHttpPort()
1003        {
1004            return httpPort;
1005        }
1006        
1007        public void setHttpPort(int port)
1008        {
1009            httpPort = port;
1010        }
1011        
1012        public String JavaDoc getHttpsHostName()
1013        {
1014            return httpsHostName;
1015        }
1016        
1017        public void setHttpsHostName(String JavaDoc hostName)
1018        {
1019            httpsHostName = hostName;
1020        }
1021        
1022        public int getHttpsPort()
1023        {
1024            return httpsPort;
1025        }
1026        
1027        public void setHttpsPort(int port)
1028        {
1029            httpsPort = port;
1030        }
1031
1032    ///////////////////////////////////////////////////////////////////////////
1033
///////// Private Methods ///////////////////////////////////////////
1034
///////////////////////////////////////////////////////////////////////////
1035

1036    private boolean isFileSourceRequired() throws IASDeploymentException
1037    {
1038        if(isUnDeploy())
1039            return false;
1040        else
1041            return true;
1042    }
1043    
1044    ///////////////////////////////////////////////////////////////////////////
1045

1046    private boolean isNameRequired() throws IASDeploymentException
1047    {
1048        if(isDeploy())
1049            return false;
1050        else
1051            return true;
1052    }
1053    
1054    ///////////////////////////////////////////////////////////////////////////
1055

1056    private boolean isContextRootRequired() throws IASDeploymentException
1057    {
1058        // it is required for WebModules that are Deployed or Redeployed
1059
return isWebModule() && ( isDeploy() || isReDeploy());
1060    }
1061    
1062    ///////////////////////////////////////////////////////////////////////////
1063

1064    private void setType(DeployableObjectType theType) throws IASDeploymentException
1065    {
1066        type = theType;
1067
1068        if(isConnectorModule())
1069            shared = true;
1070        else
1071            shared = false;
1072    }
1073    
1074    ///////////////////////////////////////////////////////////////////////////
1075

1076    /* package */ void setCommand(DeploymentCommand theCommand) throws IASDeploymentException
1077    {
1078        command = theCommand;
1079        
1080        if(command == null) {
1081            String JavaDoc msg = localStrings.getString(
1082                    "enterprise.deployment.backend.null_command_type" );
1083            throw new IASDeploymentException( msg );
1084        }
1085    }
1086    
1087    ///////////////////////////////////////////////////////////////////////////
1088

1089    private void setEnv() throws IASDeploymentException
1090    {
1091        if(instanceEnv == null) {
1092            String JavaDoc msg = localStrings.getString(
1093                    "enterprise.deployment.backend.null_instanceenvironment" );
1094            throw new IASDeploymentException( msg );
1095        }
1096        
1097        if(isApplication())
1098            appEnv = new ApplicationEnvironment(instanceEnv, name);
1099        else if(isWebModule())
1100            moduleEnv = new ModuleEnvironment(instanceEnv, name, DeployableObjectType.WEB);
1101        else if(isEjbModule())
1102            moduleEnv = new ModuleEnvironment(instanceEnv, name, DeployableObjectType.EJB);
1103        else if(isConnectorModule())
1104            moduleEnv = new ModuleEnvironment(instanceEnv, name, DeployableObjectType.CONN);
1105                else if (isAppClientModule())
1106                        moduleEnv = new ModuleEnvironment(instanceEnv, name ,DeployableObjectType.CAR);
1107        else {
1108            String JavaDoc msg = localStrings.getString(
1109                    "enterprise.deployment.backend.unknown_deployable_object",
1110                    getClass().getName() );
1111            throw new IASDeploymentException( msg );
1112        }
1113    }
1114
1115    ///////////////////////////////////////////////////////////////////////////
1116

1117    private void createName()
1118    {
1119        String JavaDoc aname = fileSource.getSource().getName();
1120        
1121        // special-case. If it's xxx.ear, the name is xxx, not xxx_ear
1122
if(isEar())
1123            name = FileUtils.makeFriendlyFilenameNoExtension(aname);
1124        else
1125            name = FileUtils.makeFriendlyFilename(aname);
1126    }
1127    
1128    /** We need to figure-out if it is REALLY an App-Redeploy very early
1129     * because DeployerFactory needs to create the right kind of Deployer object
1130     */

1131    private void checkForRedeploy() throws IASDeploymentException
1132    {
1133        if(isUnDeploy())
1134            return; // don't need to do anything!
1135

1136        assert (appEnv != null && moduleEnv == null)|| (appEnv == null && moduleEnv != null);
1137        assert !isVerified;
1138        assert StringUtils.ok(name);
1139        assert instanceEnv != null;
1140        
1141        if(moduleEnv != null)
1142        {
1143            // too difficult, and not neccessary, to figure this out here
1144
return;
1145        }
1146        
1147        try
1148        {
1149            AppsManager appMgr = new AppsManager(instanceEnv);
1150            boolean isReg = appMgr.isRegistered(name);
1151            
1152            if(forced && isReg && isDeploy())
1153                command = DeploymentCommand.REDEPLOY;
1154        }
1155        catch(Exception JavaDoc e)
1156        {
1157            throw new IASDeploymentException(e);
1158        }
1159    }
1160
1161    /**
1162     * Sets the target to as specified
1163     * @param target JSR88 target
1164     */

1165    public void setTarget(Target JavaDoc target) {
1166        this.target = target;
1167    }
1168    
1169    /**
1170     * Returns the target
1171     * @return target JSR88 Target object
1172     */

1173    public Target JavaDoc getTarget() {
1174        return target;
1175    }
1176    
1177    /**
1178     * Sets the current deployment status to as specified
1179     * @param status deployment status
1180     */

1181    public void setCurrentDeploymentStatus(DeploymentStatus status) {
1182        currentDeploymentStatus = status;
1183    }
1184
1185    /**
1186     * Returns the current deployment status
1187     * @return currentDeploymentStatus current deployment status
1188     */

1189    public DeploymentStatus getCurrentDeploymentStatus() {
1190        return currentDeploymentStatus;
1191    }
1192
1193    /**
1194     * Sets startOnUndeploy. An application is set to enabled after
1195     * deployment or association when this is true
1196     * @param startOnDeploy
1197     */

1198    public void setStartOnDeploy(boolean startOnDeploy) {
1199        this.startOnDeploy = startOnDeploy;
1200    }
1201    
1202    /**
1203     * returns true if isStartOnDeploy is true false otherwise
1204     * @return true/false
1205     */

1206    public boolean isStartOnDeploy() {
1207        return this.startOnDeploy;
1208    }
1209    
1210    /**
1211     * Sets the actioncode to as specified
1212     * @param actionCode
1213     */

1214    public void setActionCode(int actionCode){
1215        this.actionCode = actionCode;
1216    }
1217    
1218    /**
1219     * returns the actionCode
1220     * @return int action code
1221     */

1222    public int getActionCode() {
1223        return actionCode;
1224    }
1225
1226    /**
1227     * Sets cascade. Dependent resources associated with a connector resource are
1228     * destroyed if this flag is true
1229     * @param startOnDeploy
1230     */

1231    public void setCascade(boolean cascade) {
1232        this.cascade = cascade;
1233    }
1234    
1235    /**
1236     * returns true if cascade is true false otherwise
1237     * @return true/false
1238     */

1239    public boolean getCascade() {
1240        return this.cascade;
1241    }
1242    
1243    /**
1244     * Sets the descriptor associated with this request
1245     */

1246     public void setDescriptor(Application app) {
1247     this.application = app;
1248     }
1249     
1250     /**
1251      * @return the application descriptor associated with this request
1252      */

1253     public Application getDescriptor() {
1254     return application;
1255     }
1256
1257    /**
1258     * Sets the description associated with this request
1259     */

1260     public void setDescription(String JavaDoc description) {
1261         this.description = description;
1262     }
1263
1264     /**
1265      * @return the description associated with this request
1266      */

1267     public String JavaDoc getDescription() {
1268         return description;
1269     }
1270
1271     /**
1272      * Should the app or module be re-registered on fatal errors?
1273      * If false is returned, this means that it could NOT be rollbacked
1274      * to a previous working version.
1275      */

1276     public boolean getReRegisterOnFailure()
1277     {
1278        return reregisterOnFailure;
1279     }
1280
1281     void setReRegisterOnFailure(boolean b)
1282     {
1283        reregisterOnFailure = b;
1284     }
1285     
1286     /**
1287      *Releases any resources held by the deployment request, notably the
1288      *EJBClassLoader.
1289      */

1290     public void done() {
1291         if ( ! isDone) {
1292             isDone = true;
1293             if (ejbClassLoader != null && ejbClassLoader instanceof EJBClassLoader) {
1294                 ((EJBClassLoader) ejbClassLoader).done();
1295             }
1296         }
1297     }
1298     
1299    ///////////////////////////////////////////////////////////////////////////
1300

1301    private FileSource fileSource = null;
1302        private File deploymentPlan = null;
1303        private DeploymentCallback deploymentCallback = null;
1304        private boolean isAborted = false;
1305        private boolean isReload = false;
1306        private String JavaDoc targetName = null;
1307    private DeployableObjectType type = null;
1308    private DeploymentCommand command = null;
1309    private String JavaDoc name = null;
1310    private String JavaDoc contextRoot = null;
1311        private String JavaDoc defaultContextRoot
1312                = null;
1313    private InstanceEnvironment instanceEnv = null;
1314    private ApplicationEnvironment appEnv = null;
1315    private ModuleEnvironment moduleEnv = null;
1316    private File clientJar = null;
1317    private File deployedDirectory = null;
1318    private File jspDirectory = null;
1319    private File stubsDirectory = null;
1320    private File generatedXMLDirectory = null;
1321    private boolean shared = false;
1322    private boolean forced = true;
1323    private boolean isVerified = false;
1324    private boolean isVerifying = false;
1325    private boolean debug = false;
1326    private boolean noEJBC = false;
1327    private boolean precompileJSP = false;
1328    private boolean generateRMIStubs = false;
1329    private boolean availabilityEnabled = false;
1330    private boolean javaWebStartEnabled = true;
1331    private String JavaDoc libraries = null;
1332    private String JavaDoc resourceAction = null;
1333    private String JavaDoc resourceTargetList = null;
1334    private boolean directoryDeployed = false;
1335    private List JavaDoc parentClasspath = null;
1336    private ClassLoader JavaDoc parentClassLoader = null;
1337    private List JavaDoc completeClasspath = null;
1338    private List JavaDoc moduleClasspath = null;
1339    private ClassLoader JavaDoc ejbClassLoader = null;
1340    private Properties JavaDoc optionalAttributes = null;
1341    private Properties JavaDoc optionalArguments = new Properties JavaDoc();
1342    private String JavaDoc httpHostName = null;
1343    private int httpPort;
1344    private String JavaDoc httpsHostName = null;
1345    private int httpsPort;
1346    private Application application=null;
1347    private static StringManager localStrings =
1348        StringManager.getManager( DeploymentRequest.class );
1349   
1350    /** target name on which this deployment request is performed */
1351    private Target JavaDoc target = null;
1352    
1353    /** application state after Deploy/Associate */
1354    private boolean startOnDeploy = true;
1355    
1356    /** action code of this request */
1357    private int actionCode = 0;
1358    
1359    /** cascading the undeploy **/
1360    private boolean cascade = false;
1361
1362    /** current deployment status **/
1363    private DeploymentStatus currentDeploymentStatus = null;
1364    
1365    private String JavaDoc description = null;
1366
1367    /** failed directory redeploy should NOT reregister from the MBean */
1368    
1369    private boolean reregisterOnFailure = true;
1370    
1371}
1372
Popular Tags