Line 0
Link Here
|
|
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 2010 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
6 |
* The contents of this file are subject to the terms of either the GNU |
7 |
* General Public License Version 2 only ("GPL") or the Common |
8 |
* Development and Distribution License("CDDL") (collectively, the |
9 |
* "License"). You may not use this file except in compliance with the |
10 |
* License. You can obtain a copy of the License at |
11 |
* http://www.netbeans.org/cddl-gplv2.html |
12 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
13 |
* specific language governing permissions and limitations under the |
14 |
* License. When distributing the software, include this License Header |
15 |
* Notice in each file and include the License file at |
16 |
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this |
17 |
* particular file as subject to the "Classpath" exception as provided |
18 |
* by Sun in the GPL Version 2 section of the License file that |
19 |
* accompanied this code. If applicable, add the following below the |
20 |
* License Header, with the fields enclosed by brackets [] replaced by |
21 |
* your own identifying information: |
22 |
* "Portions Copyrighted [year] [name of copyright owner]" |
23 |
* |
24 |
* If you wish your version of this file to be governed by only the CDDL |
25 |
* or only the GPL Version 2, indicate your decision by adding |
26 |
* "[Contributor] elects to include this software in this distribution |
27 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
28 |
* single choice of license, a recipient has the option to distribute |
29 |
* your version of this file under either the CDDL, the GPL Version 2 or |
30 |
* to extend the choice of license to its licensees as provided above. |
31 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
32 |
* Version 2 license, then the option applies only if the new code is |
33 |
* made subject to such option by the copyright holder. |
34 |
* |
35 |
* Contributor(s): |
36 |
* |
37 |
* Portions Copyrighted 2010 Sun Microsystems, Inc. |
38 |
*/ |
39 |
|
40 |
package org.netbeans.modules.j2ee.deployment.plugins.spi.support; |
41 |
|
42 |
import java.util.Map; |
43 |
import javax.enterprise.deploy.spi.DeploymentManager; |
44 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.AntDeploymentProvider; |
45 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.DatasourceManager; |
46 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.FindJSPServlet; |
47 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.IncrementalDeployment; |
48 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.JDBCDriverDeployer; |
49 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.MessageDestinationDeployment; |
50 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.OptionalDeploymentManagerFactory; |
51 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInitializationException; |
52 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.ServerInstanceDescriptor; |
53 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.StartServer; |
54 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.TargetModuleIDResolver; |
55 |
import org.openide.WizardDescriptor.InstantiatingIterator; |
56 |
import org.openide.util.Parameters; |
57 |
|
58 |
/** |
59 |
* Provides a proxying implementation of {@link OptionalDeploymentManagerFactory}. |
60 |
* Handles optional <code>noInitializationFinish</code> attribute as a way |
61 |
* to prevent delegate's {@link #finishServerInitialization()} to be called. |
62 |
* This can be useful in situation when we want to prevent loading unnecessary |
63 |
* code (from delegate) being loaded during the {@link #finishServerInitialization()} |
64 |
* call. Designed to be used via XML layer filesystem. |
65 |
* |
66 |
* @author Petr Hejl |
67 |
* @since 1.66 |
68 |
*/ |
69 |
public final class ProxyOptionalFactory extends OptionalDeploymentManagerFactory { |
70 |
|
71 |
private final Map attributes; |
72 |
|
73 |
private final boolean noInitializationFinish; |
74 |
|
75 |
/* GuardedBy("this") */ |
76 |
private OptionalDeploymentManagerFactory delegate; |
77 |
|
78 |
private ProxyOptionalFactory(Map attributes) { |
79 |
this.attributes = attributes; |
80 |
|
81 |
Boolean finish = (Boolean) attributes.get("noInitializationFinish"); // NOI18N |
82 |
this.noInitializationFinish = finish == null ? false : finish.booleanValue(); |
83 |
} |
84 |
|
85 |
public static ProxyOptionalFactory create(Map map) { |
86 |
return new ProxyOptionalFactory(map); |
87 |
} |
88 |
|
89 |
@Override |
90 |
public boolean isCommonUIRequired() { |
91 |
return getDelegate().isCommonUIRequired(); |
92 |
} |
93 |
|
94 |
@Override |
95 |
public TargetModuleIDResolver getTargetModuleIDResolver(DeploymentManager dm) { |
96 |
return getDelegate().getTargetModuleIDResolver(dm); |
97 |
} |
98 |
|
99 |
@Override |
100 |
public StartServer getStartServer(DeploymentManager dm) { |
101 |
return getDelegate().getStartServer(dm); |
102 |
} |
103 |
|
104 |
@Override |
105 |
public ServerInstanceDescriptor getServerInstanceDescriptor(DeploymentManager dm) { |
106 |
return getDelegate().getServerInstanceDescriptor(dm); |
107 |
} |
108 |
|
109 |
@Override |
110 |
public MessageDestinationDeployment getMessageDestinationDeployment(DeploymentManager dm) { |
111 |
return getDelegate().getMessageDestinationDeployment(dm); |
112 |
} |
113 |
|
114 |
@Override |
115 |
public JDBCDriverDeployer getJDBCDriverDeployer(DeploymentManager dm) { |
116 |
return getDelegate().getJDBCDriverDeployer(dm); |
117 |
} |
118 |
|
119 |
@Override |
120 |
public IncrementalDeployment getIncrementalDeployment(DeploymentManager dm) { |
121 |
return getDelegate().getIncrementalDeployment(dm); |
122 |
} |
123 |
|
124 |
@Override |
125 |
public FindJSPServlet getFindJSPServlet(DeploymentManager dm) { |
126 |
return getDelegate().getFindJSPServlet(dm); |
127 |
} |
128 |
|
129 |
@Override |
130 |
public DatasourceManager getDatasourceManager(DeploymentManager dm) { |
131 |
return getDelegate().getDatasourceManager(dm); |
132 |
} |
133 |
|
134 |
@Override |
135 |
public AntDeploymentProvider getAntDeploymentProvider(DeploymentManager dm) { |
136 |
return getDelegate().getAntDeploymentProvider(dm); |
137 |
} |
138 |
|
139 |
@Override |
140 |
public InstantiatingIterator getAddInstanceIterator() { |
141 |
return getDelegate().getAddInstanceIterator(); |
142 |
} |
143 |
|
144 |
@Override |
145 |
public void finishServerInitialization() throws ServerInitializationException { |
146 |
if (!noInitializationFinish) { |
147 |
getDelegate().finishServerInitialization(); |
148 |
} |
149 |
} |
150 |
|
151 |
private OptionalDeploymentManagerFactory getDelegate() { |
152 |
synchronized (this) { |
153 |
if (delegate != null) { |
154 |
return delegate; |
155 |
} |
156 |
} |
157 |
|
158 |
OptionalDeploymentManagerFactory factory = (OptionalDeploymentManagerFactory) attributes.get("delegate"); // NOI18N |
159 |
Parameters.notNull("delegate", factory); // NOI18N |
160 |
|
161 |
synchronized (this) { |
162 |
if (delegate == null) { |
163 |
delegate = factory; |
164 |
} |
165 |
return delegate; |
166 |
} |
167 |
} |
168 |
|
169 |
} |