KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > genericserver > GSDeploymentFactory


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.genericserver;
21
22 import javax.enterprise.deploy.shared.factories.DeploymentFactoryManager JavaDoc;
23 import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
24 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException JavaDoc;
25 import javax.enterprise.deploy.spi.factories.DeploymentFactory JavaDoc;
26 import org.openide.ErrorManager;
27 import org.openide.util.NbBundle;
28
29 /**
30  *
31  * @author Martin Adamek
32  */

33 public class GSDeploymentFactory implements DeploymentFactory JavaDoc {
34
35     public static final String JavaDoc GENERIC_SERVER_PREFIX = "generic"; // NOI18N
36

37     private static DeploymentFactory JavaDoc instance;
38     
39     private static ErrorManager err = ErrorManager.getDefault().getInstance("org.netbeans.modules.j2ee.genericserver"); // NOI18N
40

41     public static synchronized DeploymentFactory JavaDoc create() {
42         if (instance == null) {
43             if (err.isLoggable(ErrorManager.INFORMATIONAL)) err.log("Creating Generic Server Factory"); // NOI18N
44
instance = new GSDeploymentFactory();
45             DeploymentFactoryManager.getInstance().registerDeploymentFactory(instance);
46         }
47         return instance;
48     }
49     
50     public boolean handlesURI(String JavaDoc str) {
51         return str != null && str.startsWith(GENERIC_SERVER_PREFIX);
52     }
53     
54     public DeploymentManager JavaDoc getDeploymentManager(String JavaDoc uri, String JavaDoc uname, String JavaDoc passwd) throws DeploymentManagerCreationException JavaDoc {
55         if (!handlesURI(uri)) {
56             throw new DeploymentManagerCreationException JavaDoc("Invalid URI:" + uri); // NOI18N
57
}
58         return new GSDeploymentManager();
59     }
60     
61     public DeploymentManager JavaDoc getDisconnectedDeploymentManager(String JavaDoc str) throws DeploymentManagerCreationException JavaDoc {
62         return new GSDeploymentManager();
63     }
64     
65     public String JavaDoc getProductVersion() {
66         return "0.1"; // NOI18N
67
}
68     
69     public String JavaDoc getDisplayName() {
70         return NbBundle.getMessage(GSDeploymentFactory.class, "TXT_DisplayName"); // NOI18N
71
}
72     
73 }
74
Popular Tags