alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 *
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 *
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.tomcat5;

import javax.enterprise.deploy.spi.DeploymentManager;
import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
import javax.enterprise.deploy.spi.factories.DeploymentFactory;
import org.openide.ErrorManager;
import org.openide.util.NbBundle;

/** Factory capable to create DeploymentManager that can deploy to
 * Tomcat 5.
 *
 * Tomcat URI has following format:
 * 
tomcat:[home=<home_path>:[base=<base_path>:]]<manager_app_url>
* for example *
tomcat:http://localhost:8080/manager/
* where paths values will be used as CATALINA_HOME and CATALINA_BASE properties and manager_app_url * denotes URL of manager application configured on this server and has to start with http:. * @author Radim Kubacki */ public class TomcatFactory implements DeploymentFactory { public static final String tomcatUriPrefix = "tomcat:"; // NOI18N private static TomcatFactory instance; private static ErrorManager err = ErrorManager.getDefault ().getInstance ("org.netbeans.modules.tomcat5"); // NOI18N /** Factory method to create DeploymentFactory for Tomcat. */ public static synchronized TomcatFactory create() { if (instance == null) { if (err.isLoggable (ErrorManager.INFORMATIONAL)) err.log ("Creating TomcatFactory"); // NOI18N instance = new TomcatFactory (); javax.enterprise.deploy.shared.factories.DeploymentFactoryManager .getInstance ().registerDeploymentFactory (instance); } return instance; } /** Get the {@link org.openide.ErrorManager} that logs module events. * @return Module specific ErrorManager. */ public static ErrorManager getEM () { return err; } /** Creates a new instance of TomcatFactory */ public TomcatFactory() { } /** Factory method to create DeploymentManager. * @param uri URL of configured manager application. * @param uname user with granted manager role * @param passwd user's password * @throws DeploymentManagerCreationException * @return {@link TomcatManager} */ public DeploymentManager getDeploymentManager(String uri, String uname, String passwd) throws DeploymentManagerCreationException { if (!handlesURI (uri)) { throw new DeploymentManagerCreationException ("Invalid URI:" + uri); } return new TomcatManager (true, uri.substring (tomcatUriPrefix.length ()), uname, passwd); } public DeploymentManager getDisconnectedDeploymentManager(String uri) throws DeploymentManagerCreationException { if (!handlesURI (uri)) { throw new DeploymentManagerCreationException ("Invalid URI:" + uri); } // PENDING parse to get home and base dirs return new TomcatManager (false, uri.substring (tomcatUriPrefix.length ()), null, null); } public String getDisplayName() { return NbBundle.getMessage (TomcatFactory.class, "LBL_TomcatFactory"); } public String getProductVersion() { return NbBundle.getMessage (TomcatFactory.class, "LBL_TomcatFactoryVersion"); } /** * @param str * @return true for URIs beggining with tomcat: prefix */ public boolean handlesURI(String str) { return str != null && str.startsWith (tomcatUriPrefix); } }
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.