-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e417081
commit 8517c33
Showing
8 changed files
with
169 additions
and
215 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
71 changes: 71 additions & 0 deletions
71
runtime/jvm/src/main/java/org/apache/camel/k/jvm/Language.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,71 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.camel.k.jvm; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public enum Language { | ||
Unknow("", Collections.emptyList()), | ||
JavaClass("class", Collections.singletonList("class")), | ||
JavaSource("java", Collections.singletonList("java")), | ||
JavaScript("js", Collections.singletonList("js")), | ||
Groovy("groovy", Collections.singletonList("groovy")), | ||
Xml("xml", Collections.singletonList("xml")); | ||
|
||
private final String name; | ||
private final List<String> extensions; | ||
|
||
Language(String name, List<String> extensions) { | ||
this.name = name; | ||
this.extensions = extensions; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public List<String> getExtensions() { | ||
return extensions; | ||
} | ||
|
||
public static Language fromLanguageName(String name) { | ||
for (Language language: values()) { | ||
if (language.getName().equals(name)) { | ||
return language; | ||
} | ||
} | ||
|
||
return Unknow; | ||
} | ||
|
||
public static Language fromResource(String resource) { | ||
for (Language language: values()) { | ||
String path = StringUtils.substringAfter(resource, ":"); | ||
|
||
for (String ext : language.getExtensions()) { | ||
if (path.endsWith("." + ext)) { | ||
return language; | ||
} | ||
} | ||
} | ||
|
||
return Unknow; | ||
} | ||
} |
90 changes: 0 additions & 90 deletions
90
runtime/jvm/src/main/java/org/apache/camel/k/jvm/Routes.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.