-
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.
Merge pull request #33 from cloudsoft/type-map
ToscaMetadataProvider handles all ToscaTypeProviders
- Loading branch information
Showing
12 changed files
with
199 additions
and
108 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
2 changes: 0 additions & 2 deletions
2
...brooklyn-plugin/src/main/java/alien4cloud/brooklyn/BrooklynLocationConfigurerFactory.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
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
21 changes: 0 additions & 21 deletions
21
...lyn-plugin/src/main/java/alien4cloud/brooklyn/metadata/AbstractToscaMetadataProvider.java
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...rooklyn-plugin/src/main/java/alien4cloud/brooklyn/metadata/BrooklynToscaTypeProvider.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,19 @@ | ||
package alien4cloud.brooklyn.metadata; | ||
|
||
import com.google.common.base.Optional; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
import java.util.Map; | ||
|
||
public class BrooklynToscaTypeProvider implements ToscaTypeProvider { | ||
|
||
private Map<String, String> typeMapping = ImmutableMap.of( | ||
"org.apache.brooklyn.entity.database.mysql.MySqlNode", "brooklyn.nodes.Database" | ||
); | ||
|
||
@Override | ||
public Optional<String> getToscaType(String type) { | ||
return Optional.fromNullable(typeMapping.get(type)); | ||
} | ||
|
||
} |
25 changes: 0 additions & 25 deletions
25
...klyn-plugin/src/main/java/alien4cloud/brooklyn/metadata/DefaultToscaMetadataProvider.java
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
...brooklyn-plugin/src/main/java/alien4cloud/brooklyn/metadata/DefaultToscaTypeProvider.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,15 @@ | ||
package alien4cloud.brooklyn.metadata; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
/** | ||
* A {@link ToscaTypeProvider} that always returns "brooklyn.nodes.SoftwareProcess". | ||
*/ | ||
public class DefaultToscaTypeProvider implements ToscaTypeProvider { | ||
|
||
@Override | ||
public Optional<String> getToscaType(String type) { | ||
return Optional.of("brooklyn.nodes.SoftwareProcess"); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
a4c-brooklyn-plugin/src/main/java/alien4cloud/brooklyn/metadata/ToscaMetadataProvider.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,28 @@ | ||
package alien4cloud.brooklyn.metadata; | ||
|
||
import java.util.List; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
public class ToscaMetadataProvider { | ||
|
||
private final List<ToscaTypeProvider> providers; | ||
|
||
public ToscaMetadataProvider(List<ToscaTypeProvider> providers) { | ||
this.providers = providers; | ||
} | ||
|
||
/** | ||
* @see alien4cloud.brooklyn.metadata.ToscaTypeProvider#getToscaType(String) | ||
*/ | ||
public Optional<String> getToscaType(String type) { | ||
for (ToscaTypeProvider provider : providers) { | ||
Optional<String> providedType = provider.getToscaType(type); | ||
if (providedType.isPresent()) { | ||
return providedType; | ||
} | ||
} | ||
return Optional.absent(); | ||
} | ||
|
||
} |
Oops, something went wrong.