Skip to content

Commit d33c9c4

Browse files
committed
Adding logging to investigate issues with the Module discovery Prakash has
1 parent ea8f726 commit d33c9c4

File tree

5 files changed

+59
-30
lines changed

5 files changed

+59
-30
lines changed

META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<idea-plugin version="2">
22
<id>com.headwire.aem.tooling.intellij</id>
33
<name>AEM IDE Tooling 4 IntelliJ</name>
4-
<version>1.0.3.3-beta1</version>
4+
<version>1.0.3.3-beta1-3</version>
55
<vendor email="aemintellijplugin@headwire.com" url="https://www.headwire.com/aemintellijplugin">headwire.com Inc</vendor>
66

77
<description><![CDATA[

src/main/java/com/headwire/aem/tooling/intellij/communication/ServerConnectionManager.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import com.intellij.openapi.compiler.CompileStatusNotification;
6464
import com.intellij.openapi.compiler.CompilerManager;
6565
import com.intellij.openapi.components.AbstractProjectComponent;
66+
import com.intellij.openapi.diagnostic.Logger;
6667
import com.intellij.openapi.project.Project;
6768
import com.intellij.openapi.vfs.VirtualFile;
6869
import com.intellij.openapi.wm.ToolWindow;
@@ -121,6 +122,7 @@
121122
public class ServerConnectionManager
122123
extends AbstractProjectComponent
123124
{
125+
private static final Logger LOGGER = Logger.getInstance(ServerConnectionManager.class);
124126

125127
private static List<ServerConfiguration.ServerStatus> CONFIGURATION_CHECKED = Arrays.asList(
126128
ServerConfiguration.ServerStatus.checking,
@@ -252,11 +254,11 @@ public void run() {
252254
getResponse().set(selection);
253255
}
254256
};
255-
com.headwire.aem.tooling.intellij.util.ExecutionUtil.runAndWait(runner);
256-
if(runner.getResponse().get() == 0) {
257-
// If ignore is selected then save it on that moduleL
258-
module.setIgnoreSymbolicNameMismatch(true);
259-
}
257+
// com.headwire.aem.tooling.intellij.util.ExecutionUtil.runAndWait(runner);
258+
// if(runner.getResponse().get() == 0) {
259+
// // If ignore is selected then save it on that moduleL
260+
// module.setIgnoreSymbolicNameMismatch(true);
261+
// }
260262
}
261263
Version localVersion = new Version(version);
262264
messageManager.sendDebugNotification("debug.check.osgi.module", moduleName, symbolicName, remoteVersion, localVersion);
@@ -352,7 +354,9 @@ public boolean checkBinding(@NotNull ServerConfiguration serverConfiguration, fi
352354
}
353355

354356
public List<Module> findUnboundModules(@NotNull ServerConfiguration serverConfiguration) {
357+
LOGGER.debug("Find Unbound Modules (Conf Name, Description): ", serverConfiguration.getName(), serverConfiguration.getDescription());
355358
List<UnifiedModule> unifiedModules = moduleManager.getUnifiedModules(serverConfiguration);
359+
LOGGER.debug("Found Modules (Modules): ", unifiedModules);
356360
List<Module> moduleList = new ArrayList<Module>(serverConfiguration.getModuleList());
357361
for(UnifiedModule unifiedModule : unifiedModules) {
358362
Module moduleFound = null;

src/main/java/com/headwire/aem/tooling/intellij/config/ModuleManagerImpl.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.headwire.aem.tooling.intellij.facet.SlingModuleFacetConfiguration;
2424
import com.headwire.aem.tooling.intellij.util.ComponentProvider;
2525
import com.intellij.openapi.components.AbstractProjectComponent;
26+
import com.intellij.openapi.diagnostic.Logger;
2627
import com.intellij.openapi.module.Module;
2728
import com.intellij.openapi.project.Project;
2829
import com.intellij.openapi.vfs.VirtualFile;
@@ -40,6 +41,8 @@ public class ModuleManagerImpl
4041
extends AbstractProjectComponent
4142
implements ModuleManager
4243
{
44+
private static final Logger LOGGER = Logger.getInstance(ModuleManagerImpl.class);
45+
4346
private ServerConfigurationManager serverConfigurationManager;
4447

4548
protected ModuleManagerImpl(Project project) {
@@ -124,18 +127,25 @@ public ServerConfiguration.Module findModule(@NotNull UnifiedModule unifiedModul
124127
public List<UnifiedModule> getUnifiedModules(boolean force) {
125128
List<UnifiedModule> ret = new ArrayList<UnifiedModule>();
126129
if(!force && serverConfiguration.isBound()) {
130+
LOGGER.debug("Get Unified Modules, not forced and is bound");
127131
for(ServerConfiguration.Module module: serverConfiguration.getModuleList()) {
132+
LOGGER.debug("Get Unified Modules, add unified module: ", module.getUnifiedModule().getName());
128133
ret.add(module.getUnifiedModule());
129134
}
130135
} else {
131136
Module[] modules = com.intellij.openapi.module.ModuleManager.getInstance(project).getModules();
132137
MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(project);
133138
List<MavenProject> mavenProjects = mavenProjectsManager.getNonIgnoredProjects();
134139
for(Module module : modules) {
140+
LOGGER.debug("Get Unified Modules, handle module: ", module.getName());
135141
if(!force) {
136142
// First look for a Server Configuration Module with that Module in the Module Context and see if it is bound
137143
// (If found then this is most likely)
138144
ServerConfiguration.Module scm = serverConfiguration.obtainModuleByName(module.getName());
145+
LOGGER.debug("Get Unified Modules, add unforced module (scm, name, is bound): ",
146+
scm, scm != null ? scm.getName() : "null",
147+
scm != null ? scm.isBound() : "null"
148+
);
139149
if(scm != null && scm.isBound()) {
140150
ret.add(scm.getUnifiedModule());
141151
// We found our Module so go to the next
@@ -146,6 +156,10 @@ public List<UnifiedModule> getUnifiedModules(boolean force) {
146156
// Find a corresponding Maven Project
147157
UnifiedModule unifiedModule = null;
148158
for(MavenProject mavenProject : mavenProjects) {
159+
LOGGER.debug("Get Unified Modules, handled Maven project: ",
160+
mavenProject != null ?
161+
mavenProject.getName() : "null"
162+
);
149163
if(!"pom".equalsIgnoreCase(mavenProject.getPackaging())) {
150164
// Use the Parent of the Module and Maven Pom File as they should be in the same folder
151165
//AS TODO: We might want to check if one is the child folder of the other instead being in the same
@@ -154,11 +168,13 @@ public List<UnifiedModule> getUnifiedModules(boolean force) {
154168
// Temporary issue where the IML file is not found by the Virtual File System
155169
// Fix: get the path, remove the IML file and find the Virtual File with that folder
156170
String filePath = module.getModuleFilePath();
171+
LOGGER.debug("Get Unified Modules, Maven project file path: ", filePath);
157172
if(filePath != null) {
158173
int index = filePath.lastIndexOf("/");
159174
if(index > 0 && index < filePath.length() - 2) {
160175
filePath = filePath.substring(0, index);
161176
moduleFile = project.getBaseDir().getFileSystem().findFileByPath(filePath);
177+
LOGGER.debug("Get Unified Modules, Maven project module file: ", moduleFile);
162178
}
163179
}
164180
}
@@ -167,6 +183,7 @@ public List<UnifiedModule> getUnifiedModules(boolean force) {
167183
VirtualFile mavenFolder = mavenProject.getFile().getParent();
168184
if(moduleFolder.equals(mavenFolder)) {
169185
unifiedModule = new UnifiedModuleImpl(mavenProject, module);
186+
LOGGER.debug("Get Unified Modules, Maven project module unified module: ", unifiedModule.getName());
170187
break;
171188
}
172189
}
@@ -175,31 +192,39 @@ public List<UnifiedModule> getUnifiedModules(boolean force) {
175192
if(unifiedModule != null) {
176193
if(unifiedModule.isOSGiBundle()) {
177194
if(slingModuleFacet != null) {
195+
LOGGER.debug("Get Unified Modules, check OSGi");
178196
SlingModuleFacetConfiguration slingModuleFacetConfiguration = slingModuleFacet.getConfiguration();
197+
LOGGER.debug("Get Unified Modules, sling module facet (fact, facet conf): ", slingModuleFacet, slingModuleFacetConfiguration);
179198
if(slingModuleFacetConfiguration.getModuleType() != ModuleType.bundle) {
180199
//AS TODO: Show an alert that Maven Module and Sling Facet Module type od not match
200+
LOGGER.debug("Get Unified Modules, not a maven bundle -> ignore");
181201
continue;
182202
} else {
183203
if(slingModuleFacetConfiguration.getOsgiSymbolicName().length() == 0) {
184204
//AS TODO: Show an alert that no Symbolic Name is provided
205+
LOGGER.debug("Get Unified Modules, no Symbolic Name -> ignore");
185206
continue;
186207
}
187208
if(slingModuleFacetConfiguration.isIgnoreMaven()) {
188209
if(slingModuleFacetConfiguration.getOsgiVersion().length() == 0) {
189210
//AS TODO: Show an alert that no Version is provided
211+
LOGGER.debug("Get Unified Modules, no OSGi Version -> ignore");
190212
continue;
191213
}
192214
if(slingModuleFacetConfiguration.getOsgiJarFileName().length() == 0) {
193215
//AS TODO: Show an alert that no Jar File Name is provided
216+
LOGGER.debug("Get Unified Modules, no OSGi Jar File Name -> ignore");
194217
continue;
195218
}
196219
}
197220
}
198221
}
199222
} else if(unifiedModule.isContent()) {
200223
if(slingModuleFacet != null) {
224+
LOGGER.debug("Get Unified Modules, check Content");
201225
if(slingModuleFacet.getConfiguration().getModuleType() != ModuleType.content) {
202226
//AS TODO: Warn about the miss configuration but proceed
227+
LOGGER.debug("Get Unified Modules, not a Maven content -> ignore");
203228
continue;
204229
} else {
205230
unifiedModule = new UnifiedModuleImpl(module);
@@ -208,18 +233,22 @@ public List<UnifiedModule> getUnifiedModules(boolean force) {
208233
}
209234
} else {
210235
if(slingModuleFacet != null) {
236+
LOGGER.debug("Get Unified Modules, check others");
211237
if(slingModuleFacet.getConfiguration().getModuleType() != ModuleType.excluded) {
212238
unifiedModule = new UnifiedModuleImpl(module);
213239
}
214240
}
215241
}
216242
if(unifiedModule != null) {
243+
LOGGER.debug("Get Unified Modules, finally add unified module to response: ", unifiedModule.getName());
217244
ret.add(unifiedModule);
218245
// Bind the Server Configuration Module with the Module Context
219246
ServerConfiguration.Module serverConfigurationModule = serverConfiguration.obtainModuleByName(unifiedModule.getName());
220247
if(serverConfigurationModule == null) {
248+
LOGGER.debug("Get Unified Modules, add module to server configuration: ", unifiedModule.getName());
221249
serverConfiguration.addModule(project, unifiedModule);
222250
} else {
251+
LOGGER.debug("Get Unified Modules, rebind module with server configuration: ", unifiedModule.getName());
223252
serverConfigurationModule.rebind(project, unifiedModule);
224253
}
225254
}

src/main/java/com/headwire/aem/tooling/intellij/config/ServerConfigurationManager.java

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ public boolean updateCurrentServerConfiguration() {
9797
for(ServerConfiguration serverConfiguration: serverConfigurationList) {
9898
// Clear any bindings
9999
serverConfiguration.unBind();
100+
LOGGER.debug("Update Service Configuration: '{}', '{}'", serverConfiguration.getName(), serverConfiguration.getDescription());
100101
moduleManager.getUnifiedModules(serverConfiguration);
102+
LOGGER.debug("List of Unified Modules: '{}'", moduleManager.getUnifiedModules(serverConfiguration));
101103
}
102104
return true;
103105
}
@@ -187,16 +189,10 @@ public void updateServerConfiguration(ServerConfiguration serverConfiguration) {
187189
if(configuration != null && configuration != serverConfiguration) {
188190
configuration.copy(serverConfiguration);
189191
}
190-
// ApplicationManager.getApplication().invokeLater(
191-
// new USCR(myEventDispatcher),
192-
//// new Runnable() {
193-
//// public void run() {
194-
//// myEventDispatcher.getMulticaster().configurationLoaded();
195-
//// String test = "done";
196-
//// }
197-
//// },
198-
// ModalityState.any()
199-
// );
192+
ApplicationManager.getApplication().invokeLater(
193+
new USCR(myEventDispatcher),
194+
ModalityState.any()
195+
);
200196
}
201197

202198
private static class USCR implements Runnable {
@@ -368,14 +364,6 @@ public void run(@NotNull final ProgressIndicator indicator) {
368364
indicator.setText(title);
369365
ApplicationManager.getApplication().runReadAction(
370366
new TBR(myEventDispatcher)
371-
// new Runnable() {
372-
// public void run() {
373-
// if(myEventDispatcher.getMulticaster() != null) {
374-
// myEventDispatcher.getMulticaster().configurationLoaded();
375-
// }
376-
// String test = "done";
377-
// }
378-
// }
379367
);
380368
} finally {
381369
String test2 = "done";
@@ -417,12 +405,6 @@ private static void queueLater(final Task task) {
417405
} else {
418406
app.invokeLater(
419407
new QLR(task),
420-
// new Runnable() {
421-
// public void run() {
422-
// task.queue();
423-
// String test3 = "done";
424-
// }
425-
// },
426408
ModalityState.any()
427409
);
428410
String test4 = "done";

src/main/java/com/headwire/aem/tooling/intellij/config/UnifiedModuleImpl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,18 @@ public String getMetaInfPath() {
305305
public Module getModule() {
306306
return module;
307307
}
308+
309+
public String toString() {
310+
return "UnifiedModuleImpl { " +
311+
(
312+
module == null ? "No Module" :
313+
"Name: '" + getName() + "'"
314+
) +
315+
", " +
316+
(
317+
mavenProject == null ? "No Maven Project" :
318+
"Maven Project Name: '" + mavenProject.getName() + "'"
319+
) +
320+
" }";
321+
}
308322
}

0 commit comments

Comments
 (0)