Lines 56-66
Link Here
|
56 |
import org.netbeans.modules.j2ee.deployment.impl.ui.RegistryNodeProvider; |
56 |
import org.netbeans.modules.j2ee.deployment.impl.ui.RegistryNodeProvider; |
57 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfigurationFactory; |
57 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.config.ModuleConfigurationFactory; |
58 |
import org.openide.util.Lookup; |
58 |
import org.openide.util.Lookup; |
59 |
import org.openide.cookies.InstanceCookie; |
|
|
60 |
import org.openide.nodes.Node; |
59 |
import org.openide.nodes.Node; |
61 |
import org.openide.util.NbBundle; |
60 |
import org.openide.util.NbBundle; |
62 |
import java.util.logging.Level; |
61 |
import java.util.logging.Level; |
63 |
import java.util.logging.Logger; |
62 |
import java.util.logging.Logger; |
|
|
63 |
import java.util.regex.Pattern; |
64 |
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; |
64 |
import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule; |
65 |
import javax.enterprise.deploy.spi.DeploymentManager; |
65 |
import javax.enterprise.deploy.spi.DeploymentManager; |
66 |
import javax.xml.parsers.ParserConfigurationException; |
66 |
import javax.xml.parsers.ParserConfigurationException; |
Lines 73-79
Link Here
|
73 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.RegistryNodeFactory; |
73 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.RegistryNodeFactory; |
74 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.VerifierSupport; |
74 |
import org.netbeans.modules.j2ee.deployment.plugins.spi.VerifierSupport; |
75 |
import org.openide.filesystems.FileObject; |
75 |
import org.openide.filesystems.FileObject; |
76 |
import org.openide.loaders.DataObject; |
|
|
77 |
import org.openide.util.lookup.Lookups; |
76 |
import org.openide.util.lookup.Lookups; |
78 |
import org.xml.sax.SAXException; |
77 |
import org.xml.sax.SAXException; |
79 |
|
78 |
|
Lines 85-102
Link Here
|
85 |
private static final String ATTR_NEEDS_FIND_SERVER_UI = "needsFindServerUI"; |
84 |
private static final String ATTR_NEEDS_FIND_SERVER_UI = "needsFindServerUI"; |
86 |
|
85 |
|
87 |
private final NetbeansDeployment dep; |
86 |
private final NetbeansDeployment dep; |
88 |
private final Class factoryCls; |
|
|
89 |
private final String name; |
87 |
private final String name; |
90 |
private final Lookup lkp; |
88 |
private final Lookup lkp; |
91 |
private final boolean needsFindServerUI; |
89 |
private final boolean needsFindServerUI; |
92 |
|
90 |
|
|
|
91 |
private final Pattern urlPattern; |
92 |
|
93 |
/** GuardedBy("this") */ |
93 |
/** GuardedBy("this") */ |
94 |
private DeploymentFactory factory = null; |
94 |
private DeploymentFactory factory = null; |
95 |
/** GuardedBy("this") */ |
95 |
/** GuardedBy("this") */ |
|
|
96 |
private Class factoryCls = null; |
97 |
/** GuardedBy("this") */ |
96 |
private DeploymentManager manager = null; |
98 |
private DeploymentManager manager = null; |
97 |
/** GuardedBy("this") */ |
99 |
/** GuardedBy("this") */ |
98 |
private RegistryNodeProvider nodeProvider = null; |
100 |
private RegistryNodeProvider nodeProvider = null; |
99 |
|
101 |
/** GuardedBy("this") */ |
|
|
102 |
private boolean failed; |
100 |
|
103 |
|
101 |
public Server(FileObject fo) throws IOException, ParserConfigurationException, |
104 |
public Server(FileObject fo) throws IOException, ParserConfigurationException, |
102 |
SAXException, ClassNotFoundException { |
105 |
SAXException, ClassNotFoundException { |
Lines 112-154
Link Here
|
112 |
needsFindServerUI = getBooleanValue(descriptor.getAttribute(ATTR_NEEDS_FIND_SERVER_UI), false); |
115 |
needsFindServerUI = getBooleanValue(descriptor.getAttribute(ATTR_NEEDS_FIND_SERVER_UI), false); |
113 |
|
116 |
|
114 |
dep = NetbeansDeployment.createGraph(descriptor.getInputStream()); |
117 |
dep = NetbeansDeployment.createGraph(descriptor.getInputStream()); |
|
|
118 |
FileObject factoryinstance = fo.getFileObject("Factory.instance"); |
119 |
if (factoryinstance != null) { |
120 |
Object regex = factoryinstance.getAttribute("urlPattern"); |
121 |
if (regex != null) { |
122 |
urlPattern = Pattern.compile(regex.toString()); |
123 |
} else { |
124 |
urlPattern = null; |
125 |
} |
126 |
} else { |
127 |
urlPattern = null; |
128 |
} |
115 |
|
129 |
|
116 |
lkp = Lookups.forPath(fo.getPath()); |
130 |
lkp = Lookups.forPath(fo.getPath()); |
|
|
131 |
|
132 |
if (factoryinstance == null) { |
133 |
String msg = NbBundle.getMessage(Server.class, "MSG_NoFactoryInstanceClass", name); |
134 |
LOGGER.log(Level.SEVERE, msg); |
135 |
} |
136 |
} |
137 |
|
138 |
// not really sure about this code |
139 |
private synchronized void initFactory() { |
140 |
if ((factory != null && factoryCls != null) || failed) { |
141 |
return; |
142 |
} |
143 |
|
117 |
factory = lkp.lookup(DeploymentFactory.class); |
144 |
factory = lkp.lookup(DeploymentFactory.class); |
118 |
if (factory != null) { |
145 |
if (factory != null) { |
119 |
factoryCls = factory.getClass(); |
146 |
factoryCls = factory.getClass(); |
|
|
147 |
return; |
120 |
} else { |
148 |
} else { |
121 |
FileObject factoryinstance = fo.getFileObject("Factory.instance"); |
149 |
String msg = NbBundle.getMessage(Server.class, "MSG_FactoryFailed", name); |
122 |
if (factoryinstance == null) { |
150 |
LOGGER.log(Level.SEVERE, msg); |
123 |
String msg = NbBundle.getMessage(Server.class, "MSG_NoFactoryInstanceClass", name); |
151 |
failed = true; |
124 |
LOGGER.log(Level.SEVERE, msg); |
152 |
return; |
125 |
factoryCls = null; |
|
|
126 |
return; |
127 |
} |
128 |
DataObject dobj = DataObject.find(factoryinstance); |
129 |
InstanceCookie cookie = (InstanceCookie) dobj.getCookie(InstanceCookie.class); |
130 |
if (cookie == null) { |
131 |
String msg = NbBundle.getMessage(Server.class, "MSG_FactoryFailed", name); |
132 |
LOGGER.log(Level.SEVERE, msg); |
133 |
factoryCls = null; |
134 |
return; |
135 |
} |
136 |
factoryCls = cookie.instanceClass(); |
137 |
|
153 |
|
138 |
// speculative code depending on the DF implementation and if it registers |
154 |
// FIXME what is this crap? |
139 |
// itself with DFM or not |
155 |
// DataObject dobj = DataObject.find(factoryinstance); |
140 |
|
156 |
// InstanceCookie cookie = (InstanceCookie) dobj.getCookie(InstanceCookie.class); |
141 |
try { |
157 |
// if (cookie == null) { |
142 |
factory = (DeploymentFactory) cookie.instanceCreate(); |
158 |
// String msg = NbBundle.getMessage(Server.class, "MSG_FactoryFailed", name); |
143 |
} catch (Exception e) { |
159 |
// LOGGER.log(Level.SEVERE, msg); |
144 |
LOGGER.log(Level.INFO, null, e); |
160 |
// factoryCls = null; |
145 |
} |
161 |
// return; |
|
|
162 |
// } |
163 |
// factoryCls = cookie.instanceClass(); |
164 |
// |
165 |
// // speculative code depending on the DF implementation and if it registers |
166 |
// // itself with DFM or not |
167 |
// |
168 |
// try { |
169 |
// factory = (DeploymentFactory) cookie.instanceCreate(); |
170 |
// } catch (Exception e) { |
171 |
// LOGGER.log(Level.INFO, null, e); |
172 |
// } |
146 |
} |
173 |
} |
147 |
} |
174 |
} |
148 |
|
175 |
|
149 |
private synchronized DeploymentFactory getFactory() { |
176 |
private synchronized DeploymentFactory getFactory() { |
|
|
177 |
initFactory(); |
178 |
|
150 |
if (factory == null) { |
179 |
if (factory == null) { |
151 |
|
|
|
152 |
DeploymentFactory[] factories = DeploymentFactoryManager.getInstance().getDeploymentFactories(); |
180 |
DeploymentFactory[] factories = DeploymentFactoryManager.getInstance().getDeploymentFactories(); |
153 |
for (int i = 0; i < factories.length; i++) { |
181 |
for (int i = 0; i < factories.length; i++) { |
154 |
if (factoryCls.isInstance(factories[i])) { |
182 |
if (factoryCls.isInstance(factories[i])) { |
Lines 166-172
Link Here
|
166 |
public synchronized DeploymentManager getDisconnectedDeploymentManager() |
194 |
public synchronized DeploymentManager getDisconnectedDeploymentManager() |
167 |
throws DeploymentManagerCreationException { |
195 |
throws DeploymentManagerCreationException { |
168 |
|
196 |
|
169 |
if(manager == null) { |
197 |
if (manager == null) { |
170 |
manager = getDisconnectedDeploymentManager(dep.getDisconnectedString()); |
198 |
manager = getDisconnectedDeploymentManager(dep.getDisconnectedString()); |
171 |
} |
199 |
} |
172 |
return manager; |
200 |
return manager; |
Lines 177-182
Link Here
|
177 |
} |
205 |
} |
178 |
|
206 |
|
179 |
public boolean handlesUri(String uri) { |
207 |
public boolean handlesUri(String uri) { |
|
|
208 |
if (uri != null && urlPattern != null) { |
209 |
if (!urlPattern.matcher(uri).matches()) { |
210 |
return false; |
211 |
} |
212 |
} |
213 |
|
180 |
try { |
214 |
try { |
181 |
return getFactory().handlesURI(uri); |
215 |
return getFactory().handlesURI(uri); |
182 |
} catch (Exception e) { |
216 |
} catch (Exception e) { |