तो, है जावा स्टेटमेंट के साथ कंटेनर को शुरू करना और रोकना संभव है?
आपका उपयोग केस बेहद अजीब लग रहा है (परीक्षणों के बीच कंटेनर को पुनरारंभ करना है) लेकिन चलो इस पर चर्चा नहीं करते हैं। अपने प्रश्न का उत्तर देने के लिए, हाँ यह संभव है और यह Cargo के जावा एपीआई का उपयोग करके किया जा सकता है।
एक बिलाव कंटेनर शुरू करने और अपने युद्ध की तैनाती के लिए, आपको setUp()
विधि में कुछ इस तरह कर सकते हैं:
// (1) Optional step to install the container from a URL pointing to its distribution
Installer installer = new ZipURLInstaller(new URL("http://www.apache.org/dist/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.zip"));
installer.install();
// (2) Create the Cargo Container instance wrapping our physical container
LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory()
.createConfiguration("tomcat6x"), ContainerType.INSTALLED, ConfigurationType.STANDALONE);
container = (InstalledLocalContainer) new DefaultContainerFactory()
.createContainer("tomcat6x", ContainerType.INSTALLED, configuration);
container.setHome(installer.getHome());
// (3) Statically deploy some WAR (optional)
WAR deployable = new WAR("./webapp-testing-webapp/target/webapp-testing-webapp-1.0.war");
deployable.setContext("ROOT");
configuration.addDeployable(deployable);
// (4) Start the container
container.start();
और tearDown()
विधि में इसे रोकने के।
// (6) Stop the container
container.stop();
स्रोत
2010-02-03 11:41:24
क्या आप वाकई कंटेनर को पुनरारंभ करने की आवश्यकता है और न केवल वेबपैड को पुनः लोड करें? –