This repository has been archived by the owner on Nov 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed ROOFLEX-39 and eliminated ConcurrentModificationWxception probl…
…em when adding Flex directories for monitoring.
- Loading branch information
Jeremy Grelle
committed
Mar 15, 2011
1 parent
bcfa7b6
commit 417529b
Showing
6 changed files
with
155 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,6 @@ public interface FlexOperations { | |
|
||
void createScaffoldApp(); | ||
|
||
boolean isFlexConfigured(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
....flex.roo.addon/src/main/java/org/springframework/flex/roo/addon/FlexProjectMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.springframework.flex.roo.addon; | ||
|
||
import org.springframework.flex.roo.addon.mojos.FlexPathResolver; | ||
import org.springframework.roo.metadata.AbstractMetadataItem; | ||
import org.springframework.roo.metadata.MetadataIdentificationUtils; | ||
|
||
|
||
public class FlexProjectMetadata extends AbstractMetadataItem { | ||
|
||
private static final String FLEX_PROJECT_IDENTIFIER = MetadataIdentificationUtils.create(FlexProjectMetadata.class.getName(), "flex_project"); | ||
|
||
private FlexPathResolver pathResolver; | ||
|
||
public FlexProjectMetadata(FlexPathResolver flexPathResolver) { | ||
super(FLEX_PROJECT_IDENTIFIER); | ||
this.pathResolver = flexPathResolver; | ||
} | ||
|
||
public FlexPathResolver getPathResolver() { | ||
return pathResolver; | ||
} | ||
|
||
public static final String getProjectIdentifier() { | ||
return FLEX_PROJECT_IDENTIFIER; | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
...o.addon/src/main/java/org/springframework/flex/roo/addon/FlexProjectMetadataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.springframework.flex.roo.addon; | ||
|
||
import org.apache.felix.scr.annotations.Component; | ||
import org.apache.felix.scr.annotations.Reference; | ||
import org.apache.felix.scr.annotations.Service; | ||
import org.osgi.service.component.ComponentContext; | ||
import org.springframework.flex.roo.addon.mojos.FlexPathResolver; | ||
import org.springframework.roo.file.monitor.event.FileEvent; | ||
import org.springframework.roo.file.monitor.event.FileEventListener; | ||
import org.springframework.roo.file.monitor.event.FileOperation; | ||
import org.springframework.roo.metadata.MetadataDependencyRegistry; | ||
import org.springframework.roo.metadata.MetadataIdentificationUtils; | ||
import org.springframework.roo.metadata.MetadataItem; | ||
import org.springframework.roo.metadata.MetadataProvider; | ||
import org.springframework.roo.metadata.MetadataService; | ||
import org.springframework.roo.process.manager.FileManager; | ||
import org.springframework.roo.project.Path; | ||
import org.springframework.roo.project.PathResolver; | ||
import org.springframework.roo.support.util.Assert; | ||
|
||
@Component(immediate = true) | ||
@Service | ||
public class FlexProjectMetadataProvider implements MetadataProvider, FileEventListener { | ||
|
||
private static final String PROVIDES_TYPE = MetadataIdentificationUtils.create(MetadataIdentificationUtils.getMetadataClass(FlexProjectMetadata.getProjectIdentifier())); | ||
|
||
//private static final String FLEX_GROUP = "org.springframework.flex"; | ||
|
||
@Reference | ||
private MetadataService metadataService; | ||
|
||
@Reference | ||
private MetadataDependencyRegistry metadataDependencyRegistry; | ||
|
||
@Reference | ||
private FileManager fileManager; | ||
|
||
@Reference | ||
private FlexPathResolver flexPathResolver; | ||
|
||
@Reference | ||
private PathResolver pathResolver; | ||
|
||
private String servicesConfig; | ||
|
||
protected void activate(ComponentContext context) { | ||
this.servicesConfig = pathResolver.getIdentifier(Path.SRC_MAIN_WEBAPP, "WEB-INF/flex/services-config.xml"); | ||
} | ||
|
||
public MetadataItem get(String metadataIdentificationString) { | ||
Assert.isTrue(FlexProjectMetadata.getProjectIdentifier().equals(metadataIdentificationString), "Unexpected metadata request '" + metadataIdentificationString + "' for this provider"); | ||
|
||
if (!fileManager.exists(servicesConfig)) { | ||
return null; | ||
} | ||
|
||
return new FlexProjectMetadata(flexPathResolver); | ||
} | ||
|
||
/*public void notify(String upstreamDependency, String downstreamDependency) { | ||
Assert.isTrue(MetadataIdentificationUtils.isValid(upstreamDependency), "Upstream dependency is an invalid metadata identification string ('" | ||
+ upstreamDependency + "')"); | ||
if (upstreamDependency.equals(ProjectMetadata.getProjectIdentifier())) { | ||
//recalculate the FlexProjectMetadata and notify | ||
metadataService.get(FlexProjectMetadata.getProjectIdentifier(), true); | ||
metadataDependencyRegistry.notifyDownstream(FlexProjectMetadata.getProjectIdentifier()); | ||
} | ||
}*/ | ||
|
||
public String getProvidesType() { | ||
return PROVIDES_TYPE; | ||
} | ||
|
||
public void onFileEvent(FileEvent fileEvent) { | ||
Assert.notNull(fileEvent, "File event required"); | ||
|
||
if (fileEvent.getFileDetails().getCanonicalPath().equals(servicesConfig)) { | ||
// Something happened to the services-config | ||
|
||
// Don't notify if we're shutting down | ||
if (fileEvent.getOperation() == FileOperation.MONITORING_FINISH) { | ||
return; | ||
} | ||
|
||
// Otherwise let everyone know something has happened of interest, plus evict any cached entries from the MetadataService | ||
metadataService.get(FlexProjectMetadata.getProjectIdentifier(), true); | ||
metadataDependencyRegistry.notifyDownstream(FlexProjectMetadata.getProjectIdentifier()); | ||
} | ||
} | ||
} |