index
int64
0
0
repo_id
stringlengths
9
205
file_path
stringlengths
31
246
content
stringlengths
1
12.2M
__index_level_0__
int64
0
10k
0
Create_ds/aws-msk-iam-auth/src/main/java/software/amazon/msk/auth/iam
Create_ds/aws-msk-iam-auth/src/main/java/software/amazon/msk/auth/iam/internals/AuthenticationRequestParams.java
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed 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 software.amazon.msk.auth.iam.internals; import com.amazonaws.auth.AWSCredentials; import com.amazonaws.regions.Region; import com.amazonaws.regions.RegionMetadata; import com.amazonaws.partitions.PartitionsLoader; import com.amazonaws.regions.Regions; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NonNull; import java.util.Optional; /** * This class represents the parameters that will be used to generate the Sigv4 signature * as well as the final Authentication Payload sent to the kafka broker. * The class is versioned so that it can be extended if necessary in the future. **/ @Getter @AllArgsConstructor(access = AccessLevel.PRIVATE) public class AuthenticationRequestParams { private static final String VERSION_1 = "2020_10_22"; private static final String SERVICE_SCOPE = "kafka-cluster"; private static RegionMetadata regionMetadata = new RegionMetadata(new PartitionsLoader().build()); /* we are not using the RegionMetadataFactory.create() method here as one of its path relies on the LegacyRegionXmlMetadataBuilder which does not implement tryGetRegionByEndpointDnsSuffix */ @NonNull private final String version; @NonNull private final String host; @NonNull private final AWSCredentials awsCredentials; @NonNull private final Region region; @NonNull private final String userAgent; public String getServiceScope() { return SERVICE_SCOPE; } public static AuthenticationRequestParams create(@NonNull String host, AWSCredentials credentials, @NonNull String userAgent) throws IllegalArgumentException { Region region = Optional.ofNullable(regionMetadata.tryGetRegionByEndpointDnsSuffix(host)) .orElseGet(() -> Regions.getCurrentRegion()); if (region == null) { throw new IllegalArgumentException("Host " + host + " does not belong to a valid region."); } return new AuthenticationRequestParams(VERSION_1, host, credentials, region, userAgent); } }
9,000
0
Create_ds/aws-msk-iam-auth/src/main/java/software/amazon/msk/auth/iam
Create_ds/aws-msk-iam-auth/src/main/java/software/amazon/msk/auth/iam/internals/PayloadGenerationException.java
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed 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 software.amazon.msk.auth.iam.internals; import java.io.IOException; public class PayloadGenerationException extends IOException { public PayloadGenerationException(String message, Throwable cause) { super(message, cause); } }
9,001
0
Create_ds/aws-msk-iam-auth/src/main/java/software/amazon/msk/auth/iam
Create_ds/aws-msk-iam-auth/src/main/java/software/amazon/msk/auth/iam/internals/SignedPayloadGenerator.java
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed 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 software.amazon.msk.auth.iam.internals; interface SignedPayloadGenerator { byte[] signedPayload(AuthenticationRequestParams authenticationRequestParams) throws PayloadGenerationException; }
9,002
0
Create_ds/aws-msk-iam-auth/src/main/java/software/amazon/msk/auth/iam
Create_ds/aws-msk-iam-auth/src/main/java/software/amazon/msk/auth/iam/internals/UserAgentUtils.java
/* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed 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 software.amazon.msk.auth.iam.internals; import com.amazonaws.util.ClassLoaderHelper; import com.amazonaws.util.VersionInfoUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.InputStream; import java.util.Properties; import java.util.StringJoiner; import static com.amazonaws.util.IOUtils.closeQuietly; /** * This class is used to generate the user agent for the authentication request. */ public final class UserAgentUtils { private static final Logger log = LoggerFactory.getLogger(UserAgentUtils.class); private static final String USER_AGENT_SEP = "/"; private static final String USER_AGENT_NAME = "aws-msk-iam-auth"; private static final String VERSION_INFO_FILE = "version.properties"; //TODO: UPDATE WHEN NEW VERSIONS ARE PUBLISHED. //TODO: Find a way to read the library version from a resource generated by the build system. private static final String[] AGENT_COMPONENTS = new String[] { USER_AGENT_NAME, getLibraryVersion(), VersionInfoUtils.getUserAgent() }; private static final String USER_AGENT_STRING = generateUserAgentString(AGENT_COMPONENTS); private static final String generateUserAgentString(String[] components) { StringJoiner joiner = new StringJoiner(USER_AGENT_SEP); for (String component : components) { joiner.add(component); } return joiner.toString(); } private static String getLibraryVersion() { String version = "unknown-version"; InputStream inputStream = ClassLoaderHelper.getResourceAsStream( VERSION_INFO_FILE, true, UserAgentUtils.class); Properties versionProperties = new Properties(); try { if (inputStream == null) { log.info("Unable to load version information for msk iam auth plugin"); } else { versionProperties.load(inputStream); version = versionProperties.getProperty("version"); } } catch (Exception e) { log.info("Unable to load version information for the running SDK: " + e.getMessage()); } finally { closeQuietly(inputStream, null); } return version; } public static String getUserAgentValue() { return USER_AGENT_STRING; } }
9,003
0
Create_ds/cordova-plugin-battery-status/src
Create_ds/cordova-plugin-battery-status/src/android/BatteryListener.java
/* 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.cordova.batterystatus; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.LOG; import org.apache.cordova.PluginResult; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; public class BatteryListener extends CordovaPlugin { private static final String LOG_TAG = "BatteryManager"; BroadcastReceiver receiver; private CallbackContext batteryCallbackContext = null; /** * Constructor. */ public BatteryListener() { this.receiver = null; } /** * Executes the request. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback context used when calling back into JavaScript. * @return True if the action was valid, false if not. */ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { if (action.equals("start")) { if (this.batteryCallbackContext != null) { removeBatteryListener(); } this.batteryCallbackContext = callbackContext; // We need to listen to power events to update battery status IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateBatteryInfo(intent); } }; webView.getContext().registerReceiver(this.receiver, intentFilter); } // Don't return any result now, since status results will be sent when events come in from broadcast receiver PluginResult pluginResult = new PluginResult(PluginResult.Status.NO_RESULT); pluginResult.setKeepCallback(true); callbackContext.sendPluginResult(pluginResult); return true; } else if (action.equals("stop")) { removeBatteryListener(); this.sendUpdate(new JSONObject(), false); // release status callback in JS side this.batteryCallbackContext = null; callbackContext.success(); return true; } return false; } /** * Stop battery receiver. */ public void onDestroy() { removeBatteryListener(); } /** * Stop battery receiver. */ public void onReset() { removeBatteryListener(); } /** * Stop the battery receiver and set it to null. */ private void removeBatteryListener() { if (this.receiver != null) { try { webView.getContext().unregisterReceiver(this.receiver); this.receiver = null; } catch (Exception e) { LOG.e(LOG_TAG, "Error unregistering battery receiver: " + e.getMessage(), e); } } } /** * Creates a JSONObject with the current battery information * * @param batteryIntent the current battery information * @return a JSONObject containing the battery status information */ private JSONObject getBatteryInfo(Intent batteryIntent) { JSONObject obj = new JSONObject(); try { obj.put("level", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, 0)); obj.put("isPlugged", batteryIntent.getIntExtra(android.os.BatteryManager.EXTRA_PLUGGED, -1) > 0 ? true : false); } catch (JSONException e) { LOG.e(LOG_TAG, e.getMessage(), e); } return obj; } /** * Updates the JavaScript side whenever the battery changes * * @param batteryIntent the current battery information * @return */ private void updateBatteryInfo(Intent batteryIntent) { sendUpdate(this.getBatteryInfo(batteryIntent), true); } /** * Create a new plugin result and send it back to JavaScript * * @param connection the network info to set as navigator.connection */ private void sendUpdate(JSONObject info, boolean keepCallback) { if (this.batteryCallbackContext != null) { PluginResult result = new PluginResult(PluginResult.Status.OK, info); result.setKeepCallback(keepCallback); this.batteryCallbackContext.sendPluginResult(result); } } }
9,004
0
Create_ds/camel-kameleon/src/test/java/org/apache/camel
Create_ds/camel-kameleon/src/test/java/org/apache/camel/kameleon/ComponentResourceTest.java
/* * 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.kameleon; import io.quarkus.test.junit.QuarkusTest; import io.restassured.response.Response; import org.junit.jupiter.api.Test; import javax.inject.Inject; import java.util.HashMap; import java.util.List; import static io.restassured.RestAssured.given; import org.apache.camel.kameleon.config.ConfigurationResource; import org.apache.camel.kameleon.model.KameleonConfiguration; import org.junit.jupiter.api.Assertions; @QuarkusTest public class ComponentResourceTest { @Inject ConfigurationResource configurationResource; @Test public void testComponents() { KameleonConfiguration kc = configurationResource.getKc(); kc.getTypes().forEach(camelType -> camelType.getVersions().forEach( camelVersion -> test(camelType.getName(), camelVersion.getName()) ) ); } private void test(String type, String version){ Response resp = given() .pathParam("type", type) .pathParam("version", version) .when().get("/component/{type}/{version}") .then().extract().response(); List<HashMap<String, String>> list = resp.getBody().jsonPath().getList(""); Assertions.assertTrue(list.size() > 100); Assertions.assertTrue(list.stream().filter(c -> c.get("name").contains("amqp")).count() > 0); Assertions.assertTrue(list.stream().filter(c -> c.get("name").contains("kafka")).count() > 0); } }
9,005
0
Create_ds/camel-kameleon/src/test/java/org/apache/camel
Create_ds/camel-kameleon/src/test/java/org/apache/camel/kameleon/ConfigurationResourceTest.java
/* * 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.kameleon; import io.quarkus.test.junit.QuarkusTest; import io.restassured.http.ContentType; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.junit.jupiter.api.Test; import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; @QuarkusTest public class ConfigurationResourceTest { @ConfigProperty(name = "application.version") String version; @Test public void testVersion() { given() .when().get("/configuration/version") .then() .statusCode(200) .contentType(ContentType.TEXT) .body(is(version)); } @Test public void testConfiguration() { given() .when().get("/configuration") .then() .statusCode(200) .contentType(ContentType.JSON) .body("types.size()", is(4)) .body("types[0].name", equalTo("standalone")) .body("types[1].name", equalTo("spring")) .body("types[2].name", equalTo("quarkus")); } }
9,006
0
Create_ds/camel-kameleon/src/test/java/org/apache/camel
Create_ds/camel-kameleon/src/test/java/org/apache/camel/kameleon/GeneratorResourceTest.java
/* * 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.kameleon; import io.quarkus.test.junit.QuarkusTest; import org.junit.jupiter.api.Test; @QuarkusTest public class GeneratorResourceTest { @Test public void testGenerator() { // TODO } }
9,007
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/WarmUpService.java
/* * 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.kameleon; import io.quarkus.runtime.StartupEvent; import io.quarkus.runtime.configuration.ProfileManager; import io.quarkus.vertx.ConsumeEvent; import io.vertx.core.json.JsonArray; import io.vertx.mutiny.core.eventbus.EventBus; import org.apache.camel.kameleon.component.ComponentResource; import org.apache.camel.kameleon.config.ConfigurationResource; import org.apache.camel.kameleon.generator.ProjectGeneratorService; import org.jboss.logging.Logger; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.event.Observes; import javax.inject.Inject; import java.util.List; import java.util.stream.Collectors; @ApplicationScoped public class WarmUpService { private static final Logger LOGGER = Logger.getLogger(WarmUpService.class.getName()); @Inject EventBus eventBus; @Inject ConfigurationResource configurationResource; @Inject ComponentResource componentResource; @Inject ProjectGeneratorService projectGeneratorService; void onStart(@Observes StartupEvent ev) { LOGGER.info("Data warmup start..."); if (!ProfileManager.getLaunchMode().isDevOrTest()) { configurationResource.getKc().getTypes() .forEach(camelType -> camelType.getVersions() .forEach(camelVersion -> camelVersion.getJavaVersions() .forEach(javaVersion -> eventBus.publish("warmup", new WarmupRequest(camelType.getName(), camelVersion.getName(), javaVersion)) ) ) ); } } @ConsumeEvent(value = "warmup", blocking = true) void warmup(WarmupRequest request) throws Exception { String type = request.getType(); String version = request.getVersion(); String javaVersion = request.javaVersion; LOGGER.info("Data warmup for " + type + " " + version); try { JsonArray componentArray = componentResource.components(type, version); List<String> componentList = componentArray.stream().map(o -> o.toString()).collect(Collectors.toList()); String components = componentList.stream().limit(5).collect(Collectors.joining(",")); projectGeneratorService.generate(type, version, "org.apache.camel.kameleon", "demo", "0.0.1", javaVersion, components); LOGGER.info("Data warmup done for " + type + " " + version); } catch (Exception e) { LOGGER.error(e); } } public static class WarmupRequest { public String type; public String version; public String javaVersion; public WarmupRequest() { } public WarmupRequest(String type, String version, String javaVersion) { this.type = type; this.version = version; this.javaVersion = javaVersion; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } public String getJavaVersion() { return javaVersion; } public void setJavaVersion(String javaVersion) { this.javaVersion = javaVersion; } } }
9,008
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/config/ConfigurationResource.java
/* * 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.kameleon.config; import com.fasterxml.jackson.databind.ObjectMapper; import io.quarkus.runtime.StartupEvent; import org.apache.camel.kameleon.model.KameleonConfiguration; import org.eclipse.microprofile.config.inject.ConfigProperty; import javax.enterprise.event.Observes; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import java.io.*; import java.util.stream.Collectors; @Path("/configuration") public class ConfigurationResource { @ConfigProperty(name = "application.version") String version; private String configuration; private KameleonConfiguration kc; void onStart(@Observes StartupEvent ev) { readConfiguration(); } @GET @Produces("application/json") public Response getConfiguration() throws Exception { return Response.ok(kc).build(); } @GET @Path("/version") @Produces("text/plain") public Response getVersion() throws Exception { return Response.ok(version).build(); } public KameleonConfiguration getKc() { readConfiguration(); return kc; } private void readConfiguration() { if (kc == null) { try (InputStream inputStream = getClass().getResourceAsStream("/kameleon.json"); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { configuration = reader.lines().collect(Collectors.joining(System.lineSeparator())); ObjectMapper objectMapper = new ObjectMapper(); kc = objectMapper.readValue(configuration, KameleonConfiguration.class); } catch (IOException e) { e.printStackTrace(); } } } }
9,009
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/component/ClassicComponentService.java
/* * 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.kameleon.component; import io.vertx.core.json.JsonArray; import org.apache.camel.catalog.CamelCatalog; import org.apache.camel.catalog.DefaultCamelCatalog; import org.apache.camel.catalog.DefaultRuntimeProvider; import org.apache.camel.kameleon.model.CamelComponent; import org.apache.maven.artifact.versioning.ComparableVersion; import javax.enterprise.context.ApplicationScoped; import java.util.ArrayList; import java.util.List; @ApplicationScoped public class ClassicComponentService extends AbstractComponentService { public JsonArray components(String version) throws Exception { CamelCatalog catalog = new DefaultCamelCatalog(); catalog.setRuntimeProvider(new DefaultRuntimeProvider()); ComparableVersion camelVersion = new ComparableVersion(version); List<CamelComponent> list = new ArrayList<>(); catalog.findComponentNames().forEach(name -> { String json = catalog.componentJSonSchema(name); CamelComponent component = getCamelComponent(json, "component"); if (!component.getDeprecated() && new ComparableVersion(component.getFirstVersion()).compareTo(camelVersion) != 1) { list.add(component); } }); catalog.findDataFormatNames().forEach(name -> { String json = catalog.dataFormatJSonSchema(name); CamelComponent component = getCamelComponent(json, "dataformat"); if (!component.getDeprecated() && new ComparableVersion(component.getFirstVersion()).compareTo(camelVersion) != 1) { list.add(component); } }); catalog.findLanguageNames().forEach(name -> { String json = catalog.languageJSonSchema(name); CamelComponent component = getCamelComponent(json, "language"); if (!component.getDeprecated() && new ComparableVersion(component.getFirstVersion()).compareTo(camelVersion) != 1) { list.add(component); } }); catalog.findOtherNames().forEach(name -> { String json = catalog.otherJSonSchema(name); CamelComponent component = getCamelComponent(json, "other"); if (!component.getDeprecated() && new ComparableVersion(component.getFirstVersion()).compareTo(camelVersion) != 1) { list.add(component); } }); return new JsonArray(list); } }
9,010
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/component/ComponentResource.java
/* * 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.kameleon.component; import io.vertx.core.json.JsonArray; import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("/component") public class ComponentResource { @Inject QuarkusComponentService quarkusComponentService; @Inject SpringBootComponentService springBootComponentService; @Inject ClassicComponentService classicComponentService; @Inject KameletComponentService kameletComponentService; @GET @Path("/{type}/{version}") @Produces(MediaType.APPLICATION_JSON) // @CacheResult(cacheName = "components") public JsonArray components(@PathParam("type") String type, @PathParam("version") String version) throws Exception { switch (type) { case "quarkus": return quarkusComponentService.components(); case "spring": return springBootComponentService.components(); case "kamelet": return kameletComponentService.components(); default: return classicComponentService.components(version); } } }
9,011
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/component/SpringBootComponentService.java
/* * 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.kameleon.component; import io.vertx.core.json.JsonArray; import org.apache.camel.catalog.CamelCatalog; import org.apache.camel.catalog.DefaultCamelCatalog; import org.apache.camel.catalog.quarkus.QuarkusRuntimeProvider; import org.apache.camel.kameleon.model.CamelComponent; import org.apache.camel.springboot.catalog.SpringBootRuntimeProvider; import javax.enterprise.context.ApplicationScoped; import java.util.ArrayList; import java.util.List; @ApplicationScoped public class SpringBootComponentService extends AbstractComponentService { public JsonArray components() throws Exception { CamelCatalog catalog = new DefaultCamelCatalog(); catalog.setRuntimeProvider(new SpringBootRuntimeProvider()); List<CamelComponent> list = new ArrayList<>(); catalog.findComponentNames().forEach(name -> { String json = catalog.componentJSonSchema(name); CamelComponent component = getCamelComponent(json, "component"); if (!component.getDeprecated()) { list.add(component); } }); catalog.findDataFormatNames().forEach(name -> { String json = catalog.dataFormatJSonSchema(name); CamelComponent component = getCamelComponent(json, "dataformat"); if (!component.getDeprecated()) { list.add(component); } }); catalog.findLanguageNames().forEach(name -> { String json = catalog.languageJSonSchema(name); CamelComponent component = getCamelComponent(json, "language"); if (!component.getDeprecated()) { list.add(component); } }); catalog.findOtherNames().forEach(name -> { String json = catalog.otherJSonSchema(name); CamelComponent component = getCamelComponent(json, "other"); if (!component.getDeprecated()) { list.add(component); } }); return new JsonArray(list); } }
9,012
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/component/QuarkusComponentService.java
/* * 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.kameleon.component; import io.vertx.core.json.JsonArray; import org.apache.camel.catalog.CamelCatalog; import org.apache.camel.catalog.DefaultCamelCatalog; import org.apache.camel.catalog.quarkus.QuarkusRuntimeProvider; import org.apache.camel.kameleon.model.CamelComponent; import javax.enterprise.context.ApplicationScoped; import java.util.ArrayList; import java.util.List; @ApplicationScoped public class QuarkusComponentService extends AbstractComponentService { public JsonArray components() throws Exception { CamelCatalog catalog = new DefaultCamelCatalog(); catalog.setRuntimeProvider(new QuarkusRuntimeProvider()); List<CamelComponent> list = new ArrayList<>(); catalog.findComponentNames().forEach(name -> { String json = catalog.componentJSonSchema(name); CamelComponent component = getCamelComponent(json, "component"); if (!component.getDeprecated()) { list.add(component); } }); catalog.findDataFormatNames().forEach(name -> { String json = catalog.dataFormatJSonSchema(name); CamelComponent component = getCamelComponent(json, "dataformat"); if (!component.getDeprecated()) { list.add(component); } }); catalog.findLanguageNames().forEach(name -> { String json = catalog.languageJSonSchema(name); CamelComponent component = getCamelComponent(json, "language"); if (!component.getDeprecated()) { list.add(component); } }); catalog.findOtherNames().forEach(name -> { String json = catalog.otherJSonSchema(name); CamelComponent component = getCamelComponent(json, "other"); if (!component.getDeprecated()) { list.add(component); } }); return new JsonArray(list); } }
9,013
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/component/AbstractComponentService.java
/* * 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.kameleon.component; import io.vertx.core.json.JsonObject; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.apache.camel.kameleon.model.CamelComponent; public abstract class AbstractComponentService { protected CamelComponent getCamelComponent(String json, String type) { JsonObject metadata = new JsonObject(json); return new CamelComponent( getArtifactId(metadata, type), getTitle(metadata, type), getDescription(metadata, type), getSupportLevel(metadata, type), getLabels(metadata, type), getFirstVersion(metadata, type), getArtifactId(metadata, type), isDeprecated(metadata, type), nativeSupported(metadata, type) ); } protected String getArtifactId(JsonObject metadata, String type) { try { return metadata.getJsonObject(type).getString("artifactId"); } catch (Exception e) { return ""; } } protected String getFirstVersion(JsonObject metadata, String type) { try { return metadata.getJsonObject(type).getString("firstVersion"); } catch (Exception e) { return ""; } } protected String getDescription(JsonObject metadata, String type) { try { return metadata.getJsonObject(type).getString("description"); } catch (Exception e) { return ""; } } protected String getSupportLevel(JsonObject metadata, String type) { try { return metadata.getJsonObject(type).getString("supportLevel"); } catch (Exception e) { return "Stable"; } } protected String getTitle(JsonObject metadata, String type) { try { return metadata.getJsonObject(type).getString("title"); } catch (Exception e) { return ""; } } protected List<String> getLabels(JsonObject metadata, String type) { try { return Arrays.asList(metadata.getJsonObject(type).getString("label").split(",")); } catch (Exception e) { return new ArrayList<>(0); } } protected Boolean isDeprecated(JsonObject metadata, String type) { try { return metadata.getJsonObject(type).getBoolean("deprecated"); } catch (Exception e) { return false; } } protected Boolean nativeSupported(JsonObject metadata, String type) { try { return metadata.getJsonObject(type).getBoolean("nativeSupported"); } catch (Exception e) { return false; } } }
9,014
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/component/KameletComponentService.java
/* * 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.kameleon.component; import io.vertx.core.json.JsonArray; import org.apache.camel.kameleon.model.KameletComponent; import org.apache.camel.kamelets.catalog.KameletsCatalog; import javax.enterprise.context.ApplicationScoped; import java.util.List; import java.util.stream.Collectors; @ApplicationScoped public class KameletComponentService { public JsonArray components() throws Exception { KameletsCatalog catalog = new KameletsCatalog(); List<KameletComponent> list = catalog.getKamelets().entrySet().stream() .map(e -> new KameletComponent( e.getValue().getMetadata().getName(), e.getValue().getSpec().getDefinition().getTitle(), e.getValue().getSpec().getDefinition().getDescription().split("\\r?\\n")[0], e.getValue().getMetadata().getAnnotations().get("camel.apache.org/kamelet.support.level"), List.of(e.getValue().getMetadata().getLabels().get("camel.apache.org/kamelet.type")), e.getValue().getMetadata().getAnnotations().get("camel.apache.org/kamelet.group"), e.getValue().getMetadata().getAnnotations().get("camel.apache.org/kamelet.icon") )).sorted((o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName())).collect(Collectors.toList()); return new JsonArray(list); } }
9,015
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/generator/GeneratorResource.java
/* * 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.kameleon.generator; import javax.inject.Inject; import javax.ws.rs.*; import javax.ws.rs.core.Response; import java.io.File; @Path("/generator") public class GeneratorResource { @Inject ProjectGeneratorService projectGeneratorService; @GET @Produces("application/zip") public Response get (@QueryParam("camelType") String camelType, @QueryParam("camelVersion") String camelVersion, @QueryParam("javaVersion") String javaVersion, @QueryParam("groupId") String groupId, @QueryParam("artifactId") String artifactId, @QueryParam("version") String version, @QueryParam("components") String components) throws Exception { String fileName = projectGeneratorService.generate(camelType,camelVersion, groupId, artifactId, version, javaVersion, components); File nf = new File(fileName); if (nf.exists()){ return Response.ok((Object) nf) .type("application/zip") .header("Content-Disposition", "attachment; filename=" + nf.getName()) .header("Filename", nf.getName()).build(); } return Response.serverError().build(); } @Inject RestDslGeneratorService restDslGeneratorService; @POST @Consumes({"application/yaml", "application/json"}) @Produces("application/yaml") @Path("/openapi") public Response generateRestDsl(@QueryParam("filename") String filename, String openapi) throws Exception { String yaml = restDslGeneratorService.generate(filename, openapi); return Response.ok(yaml).build(); } }
9,016
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/generator/ProjectGeneratorService.java
/* * 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.kameleon.generator; import io.vertx.mutiny.core.Vertx; import org.apache.camel.kameleon.config.ConfigurationResource; import org.apache.camel.kameleon.model.CamelType; import org.apache.camel.kameleon.model.CamelVersion; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.apache.commons.compress.utils.IOUtils; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.apache.maven.shared.invoker.*; import org.codehaus.plexus.util.xml.Xpp3Dom; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; import java.util.stream.Collectors; @ApplicationScoped public class ProjectGeneratorService { private static final String CAMEL_QUARKUS_CORE = "camel-quarkus-core"; @Inject Vertx vertx; @Inject ConfigurationResource configurationResource; static final String MAVEN_REPO = System.getProperty("java.io.tmpdir") + "/maven"; public String generate(String type, String archetypeVersion, String groupId, String artifactId, String version, String javaVersion, String components) throws Exception { String uuid = UUID.randomUUID().toString(); String folder = vertx.fileSystem().createTempDirectoryBlocking(uuid); File temp = new File(folder); String zipFileName = temp.getAbsolutePath() + "/" + artifactId + ".zip"; if (!"quarkus".equals(type)) { String folderName = temp.getAbsolutePath() + "/" + artifactId; generateClassicArchetype(temp, type, archetypeVersion, groupId, artifactId, version); Path path = Paths.get(folderName); if (Files.exists(path) && !components.isBlank() && !components.isEmpty()) { addComponents(folderName, type, components); setJavaVersion(folderName, javaVersion); packageProject(folderName, zipFileName); } else if (Files.exists(path)) { setJavaVersion(folderName, javaVersion); packageProject(folderName, zipFileName); } } else { CamelType camelType = configurationResource.getKc().getTypes().stream().filter(t -> t.getName().equals("quarkus")).findFirst().get(); String quarkusVersion = camelType.getVersions().stream().filter(cv -> cv.getName().equals(archetypeVersion)).findFirst().get().getRuntimeVersion(); generateQuarkusArchetype(temp, quarkusVersion, groupId, artifactId, version, components); String folderName = temp.getAbsolutePath() + "/code-with-quarkus"; packageProject(folderName, zipFileName); } return zipFileName; } private void addComponents(String folderName, String type, String components) throws Exception { File pom = new File(folderName, "pom.xml"); MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = reader.read(new FileReader(pom)); List<Dependency> dependencies = model.getDependencies(); List<Dependency> additional = Arrays.stream(components.split(",")).distinct().map(s -> { Dependency dep = new Dependency(); dep.setArtifactId(s); String gid = type.equals("spring") ? "org.apache.camel.springboot" : "org.apache.camel"; dep.setGroupId(gid); return dep; }).collect(Collectors.toList()); dependencies.addAll(additional); model.setDependencies(dependencies); MavenXpp3Writer writer = new MavenXpp3Writer(); writer.write(new FileWriter(pom), model); } private void setJavaVersion(String folderName, String javaVersion) throws Exception { File pom = new File(folderName, "pom.xml"); MavenXpp3Reader reader = new MavenXpp3Reader(); Model model = reader.read(new FileReader(pom)); List<Plugin> plugins = model.getBuild().getPlugins(); Plugin mavenCompiler = plugins.stream().filter(p -> p.getArtifactId().equals("maven-compiler-plugin")).findFirst().get(); Xpp3Dom config = (Xpp3Dom) mavenCompiler.getConfiguration(); if (config.getChild("source") == null) config.addChild(new Xpp3Dom("source")); if (config.getChild("target") == null) config.addChild(new Xpp3Dom("target")); config.getChild("source").setValue(javaVersion.equals("8") ? "1.8" : javaVersion); config.getChild("target").setValue(javaVersion.equals("8") ? "1.8" : javaVersion); mavenCompiler.setConfiguration(config); model.getBuild().getPlugins().removeIf(p -> p.getArtifactId().equals("maven-compiler-plugin")); model.getBuild().getPlugins().add(mavenCompiler); MavenXpp3Writer writer = new MavenXpp3Writer(); writer.write(new FileWriter(pom), model); } private void generateClassicArchetype(File folder, String type, String archetypeVersion, String groupId, String artifactId, String version) throws MavenInvocationException, IOException { CamelType camelType = configurationResource.getKc().getTypes().stream().filter(ct -> ct.getName().equals(type)).findFirst().get(); CamelVersion camelVersion = camelType.getVersions().stream().filter(cv -> cv.getName().equals(archetypeVersion)).findFirst().get(); Properties properties = new Properties(); properties.setProperty("groupId", groupId); properties.setProperty("package", generatePackageName(groupId, artifactId)); properties.setProperty("artifactId", artifactId); properties.setProperty("version", version); properties.setProperty("archetypeVersion", archetypeVersion); properties.setProperty("archetypeGroupId", camelVersion.getArchetypeGroupId()); properties.setProperty("archetypeArtifactId", camelVersion.getArchetypeArtifactId()); InvocationRequest request = new DefaultInvocationRequest(); request.setGoals(Collections.singletonList("archetype:generate")); request.setBatchMode(true); request.setProperties(properties); request.setBaseDirectory(folder); execute(request); } private void generateQuarkusArchetype(File folder, String quarkusVersion, String groupId, String artifactId, String version, String components) throws MavenInvocationException, IOException { Properties properties = new Properties(); properties.setProperty("groupId", groupId); properties.setProperty("package", generatePackageName(groupId, artifactId)); properties.setProperty("artifactId", artifactId); properties.setProperty("version", version); // properties.setProperty("noExamples", "true"); properties.setProperty("extensions", (components != null && !components.trim().isEmpty()) ? CAMEL_QUARKUS_CORE + "," + components : CAMEL_QUARKUS_CORE); InvocationRequest request = new DefaultInvocationRequest(); request.setGoals(Collections.singletonList("io.quarkus:quarkus-maven-plugin:" + quarkusVersion + ":create ")); request.setBatchMode(true); request.setProperties(properties); request.setBaseDirectory(folder); execute(request); } private static String generatePackageName(String groupId, String artifactId) { StringBuilder cleanArtifact = new StringBuilder(); for (Character c : artifactId.toCharArray()) { if (Character.isJavaIdentifierPart(c)) { cleanArtifact.append(c); } } return groupId + "." + cleanArtifact; } private void execute(InvocationRequest request) throws MavenInvocationException, IOException { Path path = Paths.get(MAVEN_REPO); Path localRepo = Files.exists(path) ? path : Files.createDirectory(path); Invoker invoker = new DefaultInvoker(); String mHome = System.getenv("MAVEN_HOME"); if (mHome == null) { throw new IllegalStateException("OS Environment MAVEN_HOME is not set"); } invoker.setMavenHome(new File(mHome)); invoker.setLocalRepositoryDirectory(localRepo.toFile()); invoker.execute(request); } private void packageProject(String folder, String filename) { try (ZipArchiveOutputStream archive = new ZipArchiveOutputStream(new FileOutputStream(filename))) { File folderToZip = new File(folder); Files.walk(folderToZip.toPath()).forEach(p -> { File file = p.toFile(); if (!file.isDirectory()) { ZipArchiveEntry entry_1 = new ZipArchiveEntry(file, file.toString().replace(folder, "")); try (FileInputStream fis = new FileInputStream(file)) { archive.putArchiveEntry(entry_1); IOUtils.copy(fis, archive); archive.closeArchiveEntry(); } catch (IOException e) { e.printStackTrace(); } } }); archive.finish(); } catch (Exception e) { e.printStackTrace(); } } }
9,017
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/generator/RestDslGeneratorService.java
/* * 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.kameleon.generator; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import io.apicurio.datamodels.Library; import io.apicurio.datamodels.openapi.models.OasDocument; import org.apache.camel.CamelContext; import org.apache.camel.generator.openapi.RestDslGenerator; import org.apache.camel.impl.lw.LightweightCamelContext; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.SafeConstructor; import javax.enterprise.context.ApplicationScoped; import java.io.FileNotFoundException; import java.util.Map; @ApplicationScoped public class RestDslGeneratorService { public String generate(String filename, String openapi) throws Exception { System.out.println(filename); System.out.println(openapi); final JsonNode node = filename.endsWith("json") ? readNodeFromJson(openapi) : readNodeFromYaml(openapi); OasDocument document = (OasDocument) Library.readDocument(node); try (CamelContext context = new LightweightCamelContext()) { return RestDslGenerator.toYaml(document).generate(context, true); } } private JsonNode readNodeFromJson(String openapi) throws Exception { final ObjectMapper mapper = new ObjectMapper(); return mapper.readTree(openapi); } private JsonNode readNodeFromYaml(String openapi) throws FileNotFoundException { final ObjectMapper mapper = new ObjectMapper(); Yaml loader = new Yaml(new SafeConstructor()); Map map = loader.load(openapi); return mapper.convertValue(map, JsonNode.class); } }
9,018
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/model/CamelType.java
/* * 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.kameleon.model; import java.util.List; public class CamelType { private String name; private String pageTitle; private String componentListTitle; private List<CamelVersion> versions; public CamelType() { } public String getName() { return name; } public void setName(String name) { this.name = name; } public List<CamelVersion> getVersions() { return versions; } public void setVersions(List<CamelVersion> versions) { this.versions = versions; } public String getPageTitle() { return pageTitle; } public void setPageTitle(String pageTitle) { this.pageTitle = pageTitle; } public String getComponentListTitle() { return componentListTitle; } public void setComponentListTitle(String componentListTitle) { this.componentListTitle = componentListTitle; } }
9,019
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/model/KameleonConfiguration.java
/* * 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.kameleon.model; import java.util.List; import org.apache.camel.kameleon.model.CamelType; public class KameleonConfiguration { private List<CamelType> types; public KameleonConfiguration() { } public List<CamelType> getTypes() { return types; } public void setTypes(List<CamelType> types) { this.types = types; } }
9,020
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/model/CamelVersion.java
/* * 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.kameleon.model; import java.util.List; public class CamelVersion { private String name; private String suffix; private List<String> javaVersions; private String defaultJava; private String runtimeVersion; // ex. Quarkus version private String archetypeGroupId; private String archetypeArtifactId; private List<CamelComponent> components; public CamelVersion() { } public CamelVersion(String name, String suffix, List<String> javaVersions, String defaultJava, String runtimeVersion, String archetypeGroupId, String archetypeArtifactId, List<CamelComponent> components) { this.name = name; this.suffix = suffix; this.javaVersions = javaVersions; this.defaultJava = defaultJava; this.runtimeVersion = runtimeVersion; this.archetypeGroupId = archetypeGroupId; this.archetypeArtifactId = archetypeArtifactId; this.components = components; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSuffix() { return suffix; } public void setSuffix(String suffix) { this.suffix = suffix; } public List<String> getJavaVersions() { return javaVersions; } public void setJavaVersions(List<String> javaVersions) { this.javaVersions = javaVersions; } public String getDefaultJava() { return defaultJava; } public void setDefaultJava(String defaultJava) { this.defaultJava = defaultJava; } public String getRuntimeVersion() { return runtimeVersion; } public void setRuntimeVersion(String runtimeVersion) { this.runtimeVersion = runtimeVersion; } public String getArchetypeGroupId() { return archetypeGroupId; } public void setArchetypeGroupId(String archetypeGroupId) { this.archetypeGroupId = archetypeGroupId; } public String getArchetypeArtifactId() { return archetypeArtifactId; } public void setArchetypeArtifactId(String archetypeArtifactId) { this.archetypeArtifactId = archetypeArtifactId; } public List<CamelComponent> getComponents() { return components; } public void setComponents(List<CamelComponent> components) { this.components = components; } }
9,021
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/model/KameletComponent.java
/* * 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.kameleon.model; import java.util.List; public class KameletComponent extends AbstractComponent { private String group; private String icon; public KameletComponent(String name, String title, String description, String supportLevel, List<String> labels, String group, String icon) { super(name, title, description, supportLevel, labels); this.group = group; this.icon = icon; } public String getGroup() { return group; } public void setGroup(String group) { this.group = group; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } }
9,022
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/model/CamelComponent.java
/* * 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.kameleon.model; import java.util.List; public class CamelComponent extends AbstractComponent { private String firstVersion; private String artifactId; private Boolean deprecated; private Boolean nativeSupported; public CamelComponent() { } public CamelComponent(String name, String title, String description, String supportLevel, List<String> labels, String firstVersion, String artifactId, Boolean deprecated, Boolean nativeSupported) { super(name, title, description, supportLevel, labels); this.firstVersion = firstVersion; this.artifactId = artifactId; this.deprecated = deprecated; this.nativeSupported = nativeSupported; } public String getFirstVersion() { return firstVersion; } public void setFirstVersion(String firstVersion) { this.firstVersion = firstVersion; } public String getArtifactId() { return artifactId; } public void setArtifactId(String artifactId) { this.artifactId = artifactId; } public Boolean getDeprecated() { return deprecated; } public void setDeprecated(Boolean deprecated) { this.deprecated = deprecated; } public Boolean getNativeSupported() { return nativeSupported; } public void setNativeSupported(Boolean nativeSupported) { this.nativeSupported = nativeSupported; } }
9,023
0
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon
Create_ds/camel-kameleon/src/main/java/org/apache/camel/kameleon/model/AbstractComponent.java
/* * 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.kameleon.model; import java.util.List; public abstract class AbstractComponent { protected String name; protected String title; protected String description; protected String supportLevel; protected List<String> labels; public AbstractComponent() { } public AbstractComponent(String name, String title, String description, String supportLevel, List<String> labels) { this.name = name; this.title = title; this.description = description; this.supportLevel = supportLevel; this.labels = labels; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getSupportLevel() { return supportLevel; } public void setSupportLevel(String supportLevel) { this.supportLevel = supportLevel; } public List<String> getLabels() { return labels; } public void setLabels(List<String> labels) { this.labels = labels; } }
9,024
0
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms/SMSTransportTest.java
/* * 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.axis2.transport.sms; import junit.framework.TestCase; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; import org.apache.axis2.engine.ListenerManager; import org.apache.axis2.Constants; import org.apache.axis2.AxisFault; import org.apache.axis2.transport.sms.smpp.SimpleSMSC; import org.apache.axis2.transport.sms.smpp.SMSCMessageNotifier; import org.apache.axis2.transport.sms.smpp.MessageHolder; import java.io.File; import java.io.IOException; public class SMSTransportTest extends TestCase { private SimpleSMSC smsc; private SMSCMessageNotifier notifier = SMSCMessageNotifier.getInstence(); private MessageHolder holder = new MessageHolder(); public SMSTransportTest() { super(SMSTransportTest.class.getName()); } protected void setUp() throws Exception { smsc = new SimpleSMSC(); smsc.startServer(); int index = 0; Thread.sleep(2000); while (!smsc.isStarted()) { index++; Thread.sleep(2000); if(index >=10){ throw new Exception("It Takes more than 10s to start The SMSC"); } } //start the Axis2 inscence File file = new File(prefixBaseDirectory(Constants.TESTING_REPOSITORY)); System.out.println(file.getAbsoluteFile()); if (!file.exists()) { throw new Exception("Repository directory does not exist"); } ConfigurationContext confContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem( file.getAbsolutePath() + "/repository", file.getAbsolutePath() + "/conf/axis2.xml"); ListenerManager lmaneger = new ListenerManager(); lmaneger.startSystem(confContext); System.out.println(" [Axis2] test Server started on port 2776 "); } public void testSMPPImplimentaion() throws Exception { notifier.addObserver(holder); holder.setHaveMessage(false); smsc.deliverSMS("0896754535", "0676556367", "SampleService:SampleInOutOperation"); int index = 0; while (!holder.isHaveMessage()) { Thread.sleep(1000); index++; if (index > 10) { throw new AxisFault("Server was shutdown as the async response take too long to complete"); } } assertEquals("Sucess", holder.getSms()); holder.setHaveMessage(false); } public static String prefixBaseDirectory(String path) { String baseDir; try { baseDir = new File(System.getProperty("basedir", ".")).getCanonicalPath(); } catch (IOException e) { throw new RuntimeException(e); } return baseDir + "/" + path; } }
9,025
0
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms/SimpleInOutMessageReceiver.java
/* * 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.axis2.transport.sms; import org.apache.axis2.receivers.AbstractInOutMessageReceiver; import org.apache.axis2.context.MessageContext; import org.apache.axis2.AxisFault; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAP11Constants; import org.apache.axiom.soap.SOAP12Constants; import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axiom.om.OMAbstractFactory; import org.apache.axiom.om.OMFactory; import org.apache.axiom.om.OMNamespace; import org.apache.axiom.om.OMElement; /** * A Simple Message reveiver used for the SMS Transport Test. */ public class SimpleInOutMessageReceiver extends AbstractInOutMessageReceiver { public void invokeBusinessLogic(MessageContext inMessageContext, MessageContext outMessageContext) throws AxisFault { log.debug("Got The message to the MessageReceiver"); String soapNamespace = inMessageContext.getEnvelope().getNamespace().getNamespaceURI(); // creating a soap factory according the the soap namespce uri SOAPFactory soapFactory = null; if (soapNamespace.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)){ soapFactory = OMAbstractFactory.getSOAP11Factory(); } else if (soapNamespace.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)){ soapFactory = OMAbstractFactory.getSOAP12Factory(); } else { System.out.println("Unknow soap message"); } SOAPEnvelope responseEnvelope = soapFactory.getDefaultEnvelope(); // creating a body element OMFactory omFactory = OMAbstractFactory.getOMFactory(); OMNamespace omNamespace = omFactory.createOMNamespace("http://sms.test","ns1"); OMElement omElement = omFactory.createOMElement("Response", omNamespace); omElement.setText("Sucess"); responseEnvelope.getBody().addChild(omElement); outMessageContext.setEnvelope(responseEnvelope); } }
9,026
0
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms/smpp/MessageHolder.java
/* * 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.axis2.transport.sms.smpp; import org.jsmpp.bean.SubmitSm; /** * Message Hoder will hold the incomming shotmessages so that they can be processed. */ public class MessageHolder implements SMSCMessageObserver{ private boolean haveMessage = false; private String sms = null; public void messsageIn(SubmitSm msg) { sms = new String(msg.getShortMessage()); sms = sms.trim(); haveMessage = true; } public boolean isHaveMessage() { return haveMessage; } public void setHaveMessage(boolean haveMessage) { this.haveMessage = haveMessage; } public String getSms() { return sms; } public void setSms(String sms) { this.sms = sms; } }
9,027
0
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms/smpp/SimpleSMSC.java
/* * 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.axis2.transport.sms.smpp; import org.jsmpp.session.*; import org.jsmpp.util.MessageId; import org.jsmpp.util.MessageIDGenerator; import org.jsmpp.util.RandomMessageIDGenerator; import org.jsmpp.bean.*; import org.jsmpp.extra.ProcessRequestException; import org.jsmpp.PDUStringException; import org.jsmpp.SMPPConstant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeoutException; import java.io.IOException; /** * This is a simulator of a Shot message service center * this is written for the test perposes of the SMPP * implementation of the SMS Transport * */ public class SimpleSMSC extends ServerResponseDeliveryAdapter implements Runnable, ServerMessageReceiverListener { private static final Integer DEFAULT_PORT = 2776; private static final Logger logger = LoggerFactory.getLogger(SimpleSMSC.class); private final ExecutorService execService = Executors.newFixedThreadPool(5); private final MessageIDGenerator messageIDGenerator = new RandomMessageIDGenerator(); private int port = DEFAULT_PORT; private SMSCMessageNotifier notifier; private boolean started =false; private SMPPServerSession serverSession = null; public SimpleSMSC() { notifier = SMSCMessageNotifier.getInstence(); } /** * Delever short message to a bineded ESMC s * @param sender * @param receiver * @param content * @throws Exception */ public void deliverSMS(String sender , String receiver , String content) throws Exception{ this.serverSession.deliverShortMessage( "CMT", TypeOfNumber.UNKNOWN , NumberingPlanIndicator.UNKNOWN , receiver , TypeOfNumber.UNKNOWN , NumberingPlanIndicator.UNKNOWN , sender , new ESMClass() , (byte)0 , (byte)0, new RegisteredDelivery(0), DataCoding.newInstance(0), content.getBytes()); } public void run() { try { SMPPServerSessionListener sessionListener = new SMPPServerSessionListener(port); System.out.println("Simple SMSC Listening on port :: " + port); started = true; while (true) { serverSession = sessionListener.accept(); serverSession.setMessageReceiverListener(this); serverSession.setResponseDeliveryListener(this); // TODO: quick fix for build instability; if not set, the Hudson build // may fail with a message such as "No response after waiting for 2000 millis // when executing deliver_sm with sessionId 8cc2b5f5 and sequenceNumber 1" serverSession.setTransactionTimer(10000); execService.execute(new WaitBindTask(serverSession)); Thread.sleep(1000); } } catch (Exception e) { logger.error("IO error occured", e); } } public MessageId onAcceptSubmitSm(SubmitSm submitSm, SMPPServerSession smppServerSession) throws ProcessRequestException { MessageId messageId = messageIDGenerator.newMessageId(); notifier.notifyObservers(submitSm); return messageId; } public SubmitMultiResult onAcceptSubmitMulti(SubmitMulti submitMulti, SMPPServerSession smppServerSession) throws ProcessRequestException { return null; } public QuerySmResult onAcceptQuerySm(QuerySm querySm, SMPPServerSession smppServerSession) throws ProcessRequestException { return null; } public void onAcceptReplaceSm(ReplaceSm replaceSm, SMPPServerSession smppServerSession) throws ProcessRequestException { } public void onAcceptCancelSm(CancelSm cancelSm, SMPPServerSession smppServerSession) throws ProcessRequestException { } public DataSmResult onAcceptDataSm(DataSm dataSm) throws ProcessRequestException { return null; } private class WaitBindTask implements Runnable { private final SMPPServerSession serverSession; public WaitBindTask(SMPPServerSession serverSession) { this.serverSession = serverSession; } public void run() { try { BindRequest bindRequest = serverSession.waitForBind(1000); logger.info("Accepting bind for session {}", serverSession.getSessionId()); try { bindRequest.accept("sys"); } catch (PDUStringException e) { logger.error("Invalid system id", e); bindRequest.reject(SMPPConstant.STAT_ESME_RSYSERR); } } catch (IllegalStateException e) { logger.error("System error", e); } catch (TimeoutException e) { logger.warn("Wait for bind has reach timeout", e); } catch (IOException e) { logger.error("Failed accepting bind request for session {}", serverSession.getSessionId()); } } } /** * Start the SimpleSMSC server */ public void startServer() { Thread t = new Thread(this); t.start(); } public int getPort() { return port; } public void setPort(int port) { this.port = port; } public boolean isStarted() { return started; } }
9,028
0
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms/smpp/SMSCMessageNotifier.java
/* * 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.axis2.transport.sms.smpp; import org.jsmpp.bean.SubmitSm; import java.util.ArrayList; /** * Manage the SMSCMessageObservers and notify them when a new SMSC message is came in */ public class SMSCMessageNotifier { private ArrayList<SMSCMessageObserver> observers = new ArrayList<SMSCMessageObserver>(); private static SMSCMessageNotifier smsMessageNotifier = new SMSCMessageNotifier(); private SMSCMessageNotifier() { } public static SMSCMessageNotifier getInstence() { return smsMessageNotifier; } /** * Notify the registered Observer about the incomming shotMessage * @param sm */ public void notifyObservers(SubmitSm sm) { for(SMSCMessageObserver o : observers) { o.messsageIn(sm); } } /** * register the SMSCMessageObserver with the SMSCMessageNotifier so that observer will get notified * when the new shot message came from the SMSC * @param o */ public void addObserver(SMSCMessageObserver o) { if(o != null) { observers.add(o); } } /** * Un register the SMSCMessageObserver so that Observer will not notifed of new Shot Message arrivals after that * @param o */ public void removeObserver(SMSCMessageObserver o) { observers.remove(o); } }
9,029
0
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/test/java/org/apache/axis2/transport/sms/smpp/SMSCMessageObserver.java
/* * 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.axis2.transport.sms.smpp; import org.apache.axis2.transport.sms.SMSMessage; import org.jsmpp.bean.SubmitSm; /** * SMSCMessageObserver will be notifed when the message came in to the SMSC * from a ESME. * To use this observer it must be regietered in the SMSCMessageNotifier */ public interface SMSCMessageObserver { /** * Notify the Mesage in to the SMSC * @param msg ShotMessage that received to the SMSC/ */ public void messsageIn(SubmitSm msg); }
9,030
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/SMSManager.java
/* * 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.axis2.transport.sms; import org.apache.axis2.description.Parameter; import org.apache.axis2.description.TransportInDescription; import org.apache.axis2.description.TransportOutDescription; import org.apache.axis2.description.ParameterInclude; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.MessageContext; import org.apache.axis2.transport.sms.smpp.SMPPImplManager; import org.apache.axis2.AxisFault; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.engine.AxisEngine; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.ArrayList; /** * SMS manager will manage all SMS implementation managers * and it will dispatch the Message to the Axis2 Engine */ public class SMSManager { private SMSImplManager currentImplimentation; private boolean inited; private ConfigurationContext configurationContext; private SMSMessageBuilder messageBuilder; private SMSMessageFormatter messageFormatter; private String phoneNumber = null; private boolean invertSourceAndDestination = true; /** the reference to the actual commons logger to be used for log messages */ protected Log log = LogFactory.getLog(this.getClass()); /** * initialize the SMS manager with TransportinDiscription * if Manager is already inited it will only set the TransportInDiscription * in the current Implimentation manager * @param transportInDescription * @param configurationContext * @throws AxisFault */ public void init(TransportInDescription transportInDescription ,ConfigurationContext configurationContext) throws AxisFault { if (!inited) { basicInit(transportInDescription , configurationContext); } Parameter builderClass = transportInDescription.getParameter(SMSTransportConstents.BUILDER_CLASS); if(builderClass == null) { messageBuilder = new DefaultSMSMessageBuilderImpl(); } else { try { messageBuilder = (SMSMessageBuilder)Class.forName((String)builderClass.getValue()).newInstance(); } catch (Exception e) { throw new AxisFault("Error while instentiating class " + builderClass.getValue() , e ); } } currentImplimentation.setTransportInDetails(transportInDescription); // get the Axis phone number form the configuration file Parameter phoneNum = transportInDescription.getParameter(SMSTransportConstents.PHONE_NUMBER); if(phoneNum != null) { this.phoneNumber = (String)phoneNum.getValue(); } inited = true; } /** * Initialize the SMS Maneger with TransportOutDiscription * if the Maneger is already inited it will set the Transport Outdetails * in the Current Implimentation Manage * @param transportOutDescription * @param configurationContext */ public void init(TransportOutDescription transportOutDescription , ConfigurationContext configurationContext) throws AxisFault { if(!inited) { basicInit(transportOutDescription , configurationContext); } Parameter formatterClass = transportOutDescription.getParameter(SMSTransportConstents.FORMATTER_CLASS); if(formatterClass == null) { messageFormatter = new DefaultSMSMessageFormatterImpl(); }else { try { messageFormatter = (SMSMessageFormatter)Class.forName((String)formatterClass.getValue()).newInstance(); } catch (Exception e) { throw new AxisFault("Error while instentiating the Class: " +formatterClass.getValue() ,e); } } currentImplimentation.setTransportOutDetails(transportOutDescription); Parameter invertS_n_D = transportOutDescription.getParameter( SMSTransportConstents.INVERT_SOURCE_AND_DESTINATION); if(invertS_n_D != null) { String val = (String)invertS_n_D.getValue(); if("false".equals(val)) { invertSourceAndDestination = false; } else if("true".equals(val)) { invertSourceAndDestination = true; } else { log.warn("Invalid parameter value set to the parameter invert_source_and_destination," + "setting the default value :true "); invertSourceAndDestination = true; } } inited = true; } private void basicInit(ParameterInclude transportDescription, ConfigurationContext configurationContext) throws AxisFault { this.configurationContext = configurationContext; Parameter p = transportDescription.getParameter(SMSTransportConstents.IMPLIMENTAION_CLASS); if (p == null) { currentImplimentation = new SMPPImplManager(); } else { String implClass = (String) p.getValue(); try { currentImplimentation = (SMSImplManager) Class.forName(implClass).newInstance(); } catch (Exception e) { throw new AxisFault("Error while instentiating class " + implClass, e); } } currentImplimentation.setSMSInManager(this); } /** * Dispatch the SMS message to Axis2 Engine * @param sms */ public void dispatchToAxis2(SMSMessage sms) { try { MessageContext msgctx = messageBuilder.buildMessaage(sms,configurationContext); msgctx.setReplyTo(new EndpointReference("sms://"+sms.getSender()+"/")); AxisEngine.receive(msgctx); } catch (InvalidMessageFormatException e) { log.debug("Invalid message format " + e); } catch (AxisFault axisFault) { log.debug(axisFault); } catch (Throwable e) { log.debug("Unknown Exception " , e); } } /** * send a SMS form the message comming form the Axis2 Engine * @param messageContext that is comming form the Axis2 */ public void sendSMS(MessageContext messageContext) { try { SMSMessage sms = messageFormatter.formatSMS(messageContext); sms.addProperty(SMSTransportConstents.INVERT_SOURCE_AND_DESTINATION ,"" + invertSourceAndDestination); currentImplimentation.sendSMS(sms); } catch (Exception e) { log.error("Error while sending the SMS " , e); } } /** * send the information SMS messages other than messages comming form the Axis2 Engine * @param sms */ public void sentInfo(SMSMessage sms) { currentImplimentation.sendSMS(sms); } public SMSImplManager getCurrentImplimentation() { return currentImplimentation; } public void setCurrentImplimentation(SMSImplManager currentImplimentation) { this.currentImplimentation = currentImplimentation; } public void start() { currentImplimentation.start(); } public void stop() { currentImplimentation.stop(); } public boolean isInited() { return inited; } public String getPhoneNumber() { return phoneNumber; } public boolean isInvertSourceAndDestination() { return invertSourceAndDestination; } public void setInvertSourceAndDestination(boolean invertSourceAndDestination) { this.invertSourceAndDestination = invertSourceAndDestination; } }
9,031
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/SMSMessageBuilder.java
/* * 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.axis2.transport.sms; import org.apache.axis2.context.MessageContext; import org.apache.axis2.context.ConfigurationContext; /** * To allow trasport to accept messages from user defeined formats * can implement this builder interface to create a implementation * that can accept a custom SMS format and build a Message to Axis2 */ public interface SMSMessageBuilder { /** * Build the Axis2 Message Context form the SMSMessage.This is respnsible for handling <br> * the content comming with the SMSMessage, handling the sender receiver details and handling the <br> * and handling the SMSMessage properties to buld the Axis2 Message Context appropriately * @param msg * @param configurationContext * @return * @throws InvalidMessageFormatException */ public MessageContext buildMessaage(SMSMessage msg, ConfigurationContext configurationContext) throws InvalidMessageFormatException; }
9,032
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/DefaultSMSMessageBuilderImpl.java
/* * 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.axis2.transport.sms; import org.apache.axis2.context.MessageContext; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.AbstractContext; import org.apache.axis2.engine.AxisConfiguration; import org.apache.axis2.description.*; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.util.MultipleEntryHashMap; import org.apache.axis2.wsdl.WSDLConstants; import org.apache.axiom.soap.SOAPEnvelope; import org.apache.axiom.soap.SOAPFactory; import org.apache.axiom.soap.SOAPBody; import org.apache.axiom.om.*; import org.apache.ws.commons.schema.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.xml.namespace.QName; import javax.activation.DataHandler; import java.util.Iterator; import java.util.Map; import java.util.HashMap; /** * Builds the MessageContext for the from the incoming SMS * accepts the RPC style message format * serviceName : operationName : param_1 = value_1 : param_2 = value_2 : param_3 = value _3 : ... : param_n = value_n * eg: Election : vote : party = XXX : candidate = XXX */ public class DefaultSMSMessageBuilderImpl implements SMSMessageBuilder { public static final String KEY_VALUE_SEPERATOR="="; /** the reference to the actual commons logger to be used for log messages */ protected Log log = LogFactory.getLog(this.getClass()); public MessageContext buildMessaage(SMSMessage msg,ConfigurationContext configurationContext) throws InvalidMessageFormatException { String message = msg.getContent(); String sender = msg.getSender(); String receiver = msg.getReceiver(); String[] parts = message.split(":"); //may be can add feature to send message format for a request like ???? if (parts.length < 2) { throw new InvalidMessageFormatException("format must be \"service_name \" : \"opration_name\" : " + "\"parm_1=val_1\" :..:\"param_n = val_n\""); } else { AxisConfiguration repo = configurationContext.getAxisConfiguration(); MessageContext messageContext = configurationContext.createMessageContext(); parts = trimSplited(parts); try { AxisService axisService = repo.getService(parts[0]); if (axisService == null) { throw new InvalidMessageFormatException("Service : " + parts[0] + "does not exsist"); } else { messageContext.setAxisService(axisService); AxisOperation axisOperation = axisService.getOperation(new QName(parts[1])); if (axisOperation == null) { throw new InvalidMessageFormatException("Operation: " + parts[1] + " does not exsist"); } messageContext.setAxisOperation(axisOperation); messageContext.setAxisMessage(axisOperation.getMessage( WSDLConstants.MESSAGE_LABEL_IN_VALUE)); Map params = getParams(parts,2); SOAPEnvelope soapEnvelope = createSoapEnvelope(messageContext , params); messageContext.setServerSide(true); messageContext.setEnvelope(soapEnvelope); TransportInDescription in = configurationContext.getAxisConfiguration().getTransportIn("sms"); TransportOutDescription out = configurationContext.getAxisConfiguration().getTransportOut("sms"); messageContext.setProperty(SMSTransportConstents.SEND_TO , sender); messageContext.setProperty(SMSTransportConstents.DESTINATION , receiver); messageContext.setTransportIn(in); messageContext.setTransportOut(out); handleSMSProperties(msg , messageContext); return messageContext; } } catch (AxisFault axisFault) { log.debug("[DefaultSMSMessageBuilderImpl] Error while extracting the axis2Service \n" + axisFault); } } return null; } /** * this will add the SMSMessage properties to the Axis2MessageContext * @param msg * @param messageContext */ protected void handleSMSProperties(SMSMessage msg , MessageContext messageContext) { Iterator<String> it = msg.getProperties().keySet().iterator(); while (it.hasNext()) { String key = it.next(); messageContext.setProperty(key , msg.getProperties().get(key)); } } private SOAPEnvelope createSoapEnvelope(MessageContext messageContext , Map params) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope inEnvlope = soapFactory.getDefaultEnvelope(); SOAPBody inBody = inEnvlope.getBody(); XmlSchemaElement xmlSchemaElement; AxisOperation axisOperation = messageContext.getAxisOperation(); if (axisOperation != null) { AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE); xmlSchemaElement = axisMessage.getSchemaElement(); if (xmlSchemaElement == null) { OMElement bodyFirstChild = soapFactory .createOMElement(messageContext.getAxisOperation().getName(), inBody); createSOAPMessageWithoutSchema(soapFactory,bodyFirstChild,params); } else { // first get the target namespace from the schema and the wrapping element. // create an OMElement out of those information. We are going to extract parameters from // url, create OMElements and add them as children to this wrapping element. String targetNamespace = xmlSchemaElement.getQName().getNamespaceURI(); QName bodyFirstChildQName; if (targetNamespace != null && !"".equals(targetNamespace)) { bodyFirstChildQName = new QName(targetNamespace, xmlSchemaElement.getName()); } else { bodyFirstChildQName = new QName(xmlSchemaElement.getName()); } OMElement bodyFirstChild = soapFactory.createOMElement(bodyFirstChildQName, inBody); // Schema should adhere to the IRI style in this. So assume IRI style and dive in to // schema XmlSchemaType schemaType = xmlSchemaElement.getSchemaType(); if (schemaType instanceof XmlSchemaComplexType) { XmlSchemaComplexType complexType = ((XmlSchemaComplexType)schemaType); XmlSchemaParticle particle = complexType.getParticle(); if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) { XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase)particle; Iterator iterator = xmlSchemaGroupBase.getItems().getIterator(); // now we need to know some information from the binding operation. while (iterator.hasNext()) { XmlSchemaElement innerElement = (XmlSchemaElement)iterator.next(); QName qName = innerElement.getQName(); if (qName == null && innerElement.getSchemaTypeName() .equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) { createSOAPMessageWithoutSchema(soapFactory, bodyFirstChild, params); break; } long minOccurs = innerElement.getMinOccurs(); boolean nillable = innerElement.isNillable(); String name = qName != null ? qName.getLocalPart() : innerElement.getName(); Object value; OMNamespace ns = (qName == null || qName.getNamespaceURI() == null || qName.getNamespaceURI().length() == 0) ? null : soapFactory.createOMNamespace( qName.getNamespaceURI(), null); // FIXME changed if ((value = params.get(name)) != null ) { addRequestParameter(soapFactory, bodyFirstChild, ns, name, value); minOccurs--; } if (minOccurs > 0) { if (nillable) { OMNamespace xsi = soapFactory.createOMNamespace( Constants.URI_DEFAULT_SCHEMA_XSI, Constants.NS_PREFIX_SCHEMA_XSI); OMAttribute omAttribute = soapFactory.createOMAttribute("nil", xsi, "true"); soapFactory.createOMElement(name, ns, bodyFirstChild) .addAttribute(omAttribute); } else { // throw new AxisFault("Required element " + qName + // " defined in the schema can not be" + // " found in the request"); } } } } } } } return inEnvlope; } private static void createSOAPMessageWithoutSchema(SOAPFactory soapFactory, OMElement bodyFirstChild, Map requestParameterMap) { // first add the parameters in the URL if (requestParameterMap != null) { Iterator requestParamMapIter = requestParameterMap.keySet().iterator(); while (requestParamMapIter.hasNext()) { String key = (String) requestParamMapIter.next(); Object value = requestParameterMap.get(key); if (value != null) { addRequestParameter(soapFactory, bodyFirstChild, null, key, value); } } } } private static void addRequestParameter(SOAPFactory soapFactory, OMElement bodyFirstChild, OMNamespace ns, String key, Object parameter) { if (parameter instanceof DataHandler) { DataHandler dataHandler = (DataHandler) parameter; OMText dataText = bodyFirstChild.getOMFactory().createOMText( dataHandler, true); soapFactory.createOMElement(key, ns, bodyFirstChild).addChild( dataText); } else { String textValue = parameter.toString(); soapFactory.createOMElement(key, ns, bodyFirstChild).setText( textValue); } } private Map getParams(String []array , int startIndex) throws InvalidMessageFormatException{ HashMap params = new HashMap(); for(int i=startIndex ;i < array.length ;i++) { String [] pramParts = array[i].split(KEY_VALUE_SEPERATOR); pramParts = trimSplited(pramParts); if(pramParts == null || pramParts.length != 2) { throw new InvalidMessageFormatException("format must be \"service_name \" : \"opration_name\" : " + "\"parm_1=val_1\" :..:\"param_n = val_n\""); } params.put( pramParts[0] , pramParts[1] ); } return params; } private String[] trimSplited(String parts[]) { if (parts == null) { return null; } for (int i = 0; i < parts.length; i++) { parts[i] = parts[i].trim(); } return parts; } }
9,033
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/SMSMessage.java
/* * 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.axis2.transport.sms; import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.Properties; import java.util.Map; import java.util.HashMap; /** * SMS message is a atomic object wich carries a SMS * SMS has can be either a IN message or a OUT message * which will have the details sender , receiver ,Content and properties * sender , receiver has a implied meaning with the Message direction * <br> * eg: * in a IN_MESSAGE sender : the phone number of the phone that sms has been sent to axis2 * receiver : the phone number given from the SMSC to the Axis2 * in a OUT_MESSAGE sender : the phone number given from the SMSC to the Axis2 * receiver : the phone number of the phone that sms created from Axis2 must deliver to */ public class SMSMessage { private String sender; private String receiver; private String content; private int direction; private Map<String ,Object> properties = new HashMap<String , Object>(); public static int IN_MESSAGE =1; public static int OUT_MESSAGE =2; /** * * @param sender * @param reciever * @param content * @param direction * @throws AxisFault */ public SMSMessage(String sender ,String reciever, String content , int direction) throws AxisFault { this.sender = sender; this.content = content; this.receiver = reciever; if (direction == IN_MESSAGE || direction == OUT_MESSAGE ) { this.direction = direction; } else { throw new AxisFault("Message must be in or out"); } } /** * Retuen the Phone Number of the Sender * @return String that contain the senders phone Number */ public String getSender() { return sender; } /** * Return the phone Number that SMS must be received to * @return String that Contain the receivers phone Number */ public String getReceiver() { return receiver; } /** * Return The Contect that will be send with the SMS * @return String that contain the content */ public String getContent() { return content; } /** * return the Message Direction of the SMSMessage * That should be either SMS_IN_MESSAGE :1 * Or SMS_OUT_MESSAGE : 2 * @return int that will infer the message direction */ public int getDirection() { return direction; } /** * add the Implementation level properties that properties will be add to the Axis2 Message Context * @param key * @param value */ public void addProperty(String key, Object value) { if(key != null && value != null) { properties.put(key,value); } } /** * Return the properties of the SMS message * @return */ public Map<String , Object> getProperties() { return properties; } }
9,034
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/SMSTransportConstents.java
/* * 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.axis2.transport.sms; /** * Keeps the constets that are need for SMS Transport.Currently The code of the Class is divided in to three sections * for the keep the clarity * 1) SMS Transport Constents : add the constents to this section if you need to add new constents to the gneric * SMSTransport level. * 2) SMPP Constents : SMPP is one implimentation of SMSTransport.Add Constents to this section if you need to add * constents related to SMPP section * 3) GSM Constets : This a another implimentation. Add Constents to this section if you need to add constents related * to GSM section * * if you are going to add a another SMS implimentation add a another section to this class eg:"XXX Transport Constents" */ public class SMSTransportConstents { /** * SMS Transport Constents */ public static String IMPLIMENTAION_CLASS = "smsImplClass"; public static String BUILDER_CLASS = "builderClass"; public static String FORMATTER_CLASS ="formatterClass"; public static String SEND_TO="sms_sender"; public static String DESTINATION = "sms_destination"; /** * if this paprameter is set true in the Transport sender configuration. * sender will use message source specific parameters as destination parameters when sending the message * the default value is true. * * eg: in a SMPP Transport message * SOURCE_ADDRESS_TON will be used as the DESTINATION_ADDRESS_TON is this parameter is not set to false. */ public static String INVERT_SOURCE_AND_DESTINATION = "invert_source_and_destination"; public static String PHONE_NUMBER = "phoneNumber"; /** * SMPP constents */ public static String SYSTEM_TYPE = "systemType"; public static String SYSTEM_ID = "systemId"; public static String PASSWORD = "password"; public static String HOST = "host"; public static String PORT = "port"; /** * GSM Constents */ public static String MODEM_GATEWAY_ID = "gateway_id"; public static String COM_PORT = "com_port"; public static String BAUD_RATE = "baud_rate"; public static String MANUFACTURER = "manufacturer"; public static String MODEL = "model"; public static String MODEM_POLL_INTERVAL="modem_poll_interval"; }
9,035
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/SMSMessageReciever.java
/* * 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.axis2.transport.sms; import org.apache.axis2.AxisFault; import org.apache.axis2.addressing.EndpointReference; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.MessageContext; import org.apache.axis2.context.SessionContext; import org.apache.axis2.description.TransportInDescription; import org.apache.axis2.transport.TransportListener; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class SMSMessageReciever implements TransportListener { private SMSManager smsManeger; /** the reference to the actual commons logger to be used for log messages */ protected Log log = LogFactory.getLog(this.getClass()); public void init(ConfigurationContext configurationContext, TransportInDescription transportInDescription) throws AxisFault { smsManeger = new SMSManager(); smsManeger.init(transportInDescription , configurationContext); } public void start() throws AxisFault { if(smsManeger.isInited()) { smsManeger.start(); } } public void stop() throws AxisFault { if(smsManeger.isInited()) { smsManeger.stop(); } } public EndpointReference getEPRForService(String s, String s1) throws AxisFault { return null; } public EndpointReference[] getEPRsForService(String s, String s1) throws AxisFault { if (smsManeger.getPhoneNumber() != null) { // need to change this after sms transport have a proper standered epr return new EndpointReference[]{ new EndpointReference("sms://"+smsManeger.getPhoneNumber()+"/")}; } else { log.debug("Unable to generate EPR for the transport sms"); } return null; } public SessionContext getSessionContext(MessageContext messageContext) { return null; } public void destroy() { } }
9,036
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/DefaultSMSMessageFormatterImpl.java
/* * 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.axis2.transport.sms; import org.apache.axis2.context.MessageContext; import org.apache.axis2.AxisFault; import org.apache.axis2.transport.sms.smpp.SMPPTransportOutDetails; import org.apache.axis2.description.Parameter; import org.apache.axiom.om.OMElement; import java.util.Iterator; public class DefaultSMSMessageFormatterImpl implements SMSMessageFormatter{ public SMSMessage formatSMS(MessageContext messageContext) throws Exception { String sendTo; //phone number set at the Transport configuration get the precidence String axis2PhoneNumber = SMPPTransportOutDetails.getInstence().getPhoneNumber() ; Object s= messageContext.getProperty(SMSTransportConstents.SEND_TO); if (s != null) { sendTo = (String)s; } else { sendTo = SMSTransportUtils.getPhoneNumber(messageContext.getTo()); } OMElement elem = messageContext.getEnvelope().getBody(); String content = "Empty responce"; boolean cont = true; while(cont) { content = elem.getFirstElement().getText(); if("".equals(content) || content == null) { elem = elem.getFirstElement(); if(elem == null) { cont = false; content = "Empty responce"; } } else { cont = false; } } //if not configured in the Transport configuration if("0000".equals(axis2PhoneNumber)) { String axisPhone = (String)messageContext.getProperty(SMSTransportConstents.DESTINATION); if(axisPhone != null) { axis2PhoneNumber = axisPhone; } } SMSMessage sms = new SMSMessage( axis2PhoneNumber, sendTo , content ,SMSMessage.OUT_MESSAGE); handleMessageContextProperties(sms,messageContext); return sms; } private void handleMessageContextProperties(SMSMessage sms , MessageContext messageContext) { Iterator<String> it = messageContext.getPropertyNames(); while(it.hasNext()) { String key = it.next(); sms.addProperty(key , messageContext.getProperty(key)); } } }
9,037
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/SMSTransportUtils.java
/* * 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.axis2.transport.sms; import org.apache.axis2.description.Parameter; import org.apache.axis2.context.MessageContext; import org.apache.axis2.addressing.EndpointReference; import java.util.ArrayList; public class SMSTransportUtils { /** * Given the array list of parameters and a name of the parameter * it will return the Value of that Parameter * * @param list * @param name * @return Object that stores the value of that Parameter */ public static Object getParameterValue(ArrayList<Parameter> list, String name) { if (name == null) { return null; } for (Parameter p : list) { if (name.equals(p.getName())) { return p.getValue(); } } return null; } /** * given the EPR it will return the phone number that the EPR represents * this assumes a EPR of format * sms://<phone_number>/ * * @param epr * @return */ public static String getPhoneNumber(EndpointReference epr) throws Exception { String eprAddress = epr.getAddress(); String protocal = eprAddress.substring(0, 3); if (protocal != null && protocal.equals("sms")) { String parts[] = eprAddress.split("/"); String phoneNumber = parts[2]; return phoneNumber; } else { throw new Exception("Invalid Epr for the SMS Transport : Epr must be of format sms://<phone_number>/"); } } }
9,038
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/SMSImplManager.java
/* * 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.axis2.transport.sms; import org.apache.axis2.description.Parameter; import org.apache.axis2.description.TransportInDescription; import org.apache.axis2.description.TransportOutDescription; import org.apache.axis2.AxisFault; import java.util.ArrayList; /** * Interface for Specefic SMS implmentations * SMS Manager will manage these implmentations */ public interface SMSImplManager { /** * start the Underlying SMS implmentation */ public void start(); /** * stop the Underlying SMS implementation */ public void stop(); /** * set the Transport out details that is needed for the implementation manager * @param transportOutDetails * @throws AxisFault */ public void setTransportOutDetails(TransportOutDescription transportOutDetails) throws AxisFault; /** * set the Transport in details that is needed for the implementation manager * @param transportInDetails * @throws AxisFault */ public void setTransportInDetails(TransportInDescription transportInDetails) throws AxisFault; /** * send the SMS that is passed as a parameter using the current implimentation (To know the Content of the SMSMessage Look in to the documantaion of * the SMSMessage ) * @param sm SMSMessage to be send */ public void sendSMS(SMSMessage sm); /** * set the SMS manager that carries out SMS In task to the SMSImplimentaion * @param manager */ public void setSMSInManager(SMSManager manager); /** * get the refferance to the SMSMeneger instance that the implimentaion has * @return */ public SMSManager getSMSInManager(); }
9,039
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/InvalidMessageFormatException.java
/* * 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.axis2.transport.sms; public class InvalidMessageFormatException extends Exception{ /** * * @param message that need to be send back to the sender reporing his error */ public InvalidMessageFormatException(String message) { this.messageToSendBack = message; } String messageToSendBack; public String getMessageToSendBack() { return messageToSendBack; } }
9,040
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/SMSMessageFormatter.java
/* * 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.axis2.transport.sms; import org.apache.axis2.context.MessageContext; import org.apache.axis2.AxisFault; /** * Interface for the Message formatters that build the out going SMSMessage from th Axis2 Message Context */ public interface SMSMessageFormatter { /** * format the out going SMS message from the MessageContext * @param messageContext * @return SMSMessage thats going to submited to the SMSC */ public SMSMessage formatSMS(MessageContext messageContext) throws Exception; }
9,041
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/SMSSender.java
/* * 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.axis2.transport.sms; import org.apache.axis2.handlers.AbstractHandler; import org.apache.axis2.transport.TransportSender; import org.apache.axis2.transport.OutTransportInfo; import org.apache.axis2.transport.base.AbstractTransportSender; import org.apache.axis2.context.MessageContext; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.AxisFault; import org.apache.axis2.description.TransportOutDescription; /** * Transport sender that sends the SMS messages form the Axis2 Engine */ public class SMSSender extends AbstractTransportSender { private SMSManager smsManager; public void cleanup(MessageContext msgContext) throws AxisFault { } public void sendMessage(MessageContext msgCtx, String targetEPR, OutTransportInfo outTransportInfo) throws AxisFault { smsManager.sendSMS(msgCtx); } public void init(ConfigurationContext confContext, TransportOutDescription transportOut) throws AxisFault { smsManager = new SMSManager(); smsManager.init(transportOut, confContext); } public void stop() { smsManager.stop(); } }
9,042
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/gsm/GSMImplManager.java
/* * 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.axis2.transport.sms.gsm; import org.apache.axis2.transport.sms.SMSImplManager; import org.apache.axis2.transport.sms.SMSMessage; import org.apache.axis2.transport.sms.SMSTransportConstents; import org.apache.axis2.transport.sms.SMSManager; import org.apache.axis2.description.TransportOutDescription; import org.apache.axis2.description.TransportInDescription; import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.smslib.*; import org.smslib.modem.SerialModemGateway; /** * Manage the GSM implimentation of the SMS Transport * To use this with the axis2 to it must be spcified as a implimentation class in the Axis2 XML * following is a Sample configuration * <transportReceiver name="sms" * class="org.apache.axis2.transport.sms.SMSMessageReciever"> * * <parameter name="smsImplClass">org.apache.axis2.transport.sms.gsm.GSMImplManager</parameter> * <parameter name="com_port">/dev/ttyUSB0</parameter> * <parameter name="gateway_id">modem.ttyUSB0</parameter> * <parameter name="baud_rate">115200</parameter> * <parameter name="manufacturer">HUAWEI</parameter> * <parameter name="model">E220</parameter> * </transportReceiver> * * */ public class GSMImplManager implements SMSImplManager { /** the reference to the actual commons logger to be used for log messages */ protected Log log = LogFactory.getLog(this.getClass()); private GSMTransportInDetails gsmTransportInDetails = GSMTransportInDetails.getInstance(); private GSMTransportOutDetails gsmTransportOutDetails = GSMTransportOutDetails.getInstance(); private GSMDispatcher dispatcher; private Service service = null; private SerialModemGateway gateway; private GSMServiceRepository serviceRepo = GSMServiceRepository.getInstence(); private SMSManager smsInManeger; public void start() { if(serviceRepo.gatewayInUse(gsmTransportInDetails.getGatewayId())) { service = serviceRepo.getService(gsmTransportInDetails.getGatewayId()); return; } service = new Service(); gateway= new SerialModemGateway(gsmTransportInDetails.getGatewayId(), gsmTransportInDetails.getComPort(), gsmTransportInDetails.getBaudRate(),gsmTransportInDetails.getManufacturer(), gsmTransportInDetails.getModel()); // Set the modem protocol to PDU (alternative is TEXT). PDU is the default, anyway... gateway.setProtocol(AGateway.Protocols.PDU); // Do we want the Gateway to be used for Inbound messages? gateway.setInbound(true); // Do we want the Gateway to be used for Outbound messages? gateway.setOutbound(true); // Let SMSLib know which is the SIM PIN. gateway.setSimPin("0000"); try { // Add the Gateway to the Service object. this.service.addGateway(gateway); // Start! (i.e. connect to all defined Gateways) this.service.startService(); serviceRepo.addService(gsmTransportInDetails.getGatewayId(), service); dispatcher = new GSMDispatcher(service , smsInManeger); dispatcher.setPollInterval(gsmTransportInDetails.getModemPollInterval()); Thread thread = new Thread(dispatcher); thread.start(); System.out.println("[Axis2] Started in Port :" + gsmTransportInDetails.getComPort() +" "); } catch (Exception e) { log.error(e); } } public void stop() { try { dispatcher.stopPolling(); service.stopService(); if(serviceRepo.gatewayInUse(gsmTransportInDetails.getGatewayId())) { serviceRepo.removeService(gsmTransportInDetails.getGatewayId()); } if(serviceRepo.gatewayInUse(gsmTransportOutDetails.getGatewayId())) { serviceRepo.removeService(gsmTransportOutDetails.getGatewayId()); } } catch (Exception e) { log.error(e); } } public void setTransportOutDetails(TransportOutDescription transportOutDetails) throws AxisFault { if (transportOutDetails.getParameter(SMSTransportConstents.MODEM_GATEWAY_ID) != null) { gsmTransportOutDetails.setGatewayId((String) transportOutDetails.getParameter( SMSTransportConstents.MODEM_GATEWAY_ID).getValue()); } else { throw new AxisFault("GATEWAY ID NOT SET for the SMS transprot"); } if (transportOutDetails.getParameter(SMSTransportConstents.COM_PORT) != null) { gsmTransportOutDetails.setComPort((String) transportOutDetails.getParameter( SMSTransportConstents.COM_PORT).getValue()); } else { throw new AxisFault("COM PORT NOT SET for the SMS transprot"); } if (transportOutDetails.getParameter(SMSTransportConstents.BAUD_RATE) != null) { int bRate = Integer.parseInt((String) transportOutDetails.getParameter( SMSTransportConstents.BAUD_RATE).getValue()); gsmTransportOutDetails.setBaudRate(bRate); } else { throw new AxisFault("BAUD RATE NOT SET for the SMS transprot"); } if (transportOutDetails.getParameter(SMSTransportConstents.MANUFACTURER) != null) { gsmTransportOutDetails.setManufacturer((String) transportOutDetails.getParameter( SMSTransportConstents.MANUFACTURER).getValue()); } else { throw new AxisFault("Manufactuer NOT SET for the SMS transprot"); } if (transportOutDetails.getParameter(SMSTransportConstents.MODEL) != null) { gsmTransportOutDetails.setModel((String) transportOutDetails.getParameter( SMSTransportConstents.MODEL).getValue()); } else { throw new AxisFault("Model NOT SET for the SMS transprot"); } } public void setTransportInDetails(TransportInDescription transportInDetails) throws AxisFault { if (transportInDetails.getParameter(SMSTransportConstents.MODEM_GATEWAY_ID) != null) { gsmTransportInDetails.setGatewayId((String) transportInDetails.getParameter( SMSTransportConstents.MODEM_GATEWAY_ID).getValue()); } else { throw new AxisFault("GATEWAY ID NOT SET for the SMS transprot"); } if (transportInDetails.getParameter(SMSTransportConstents.COM_PORT) != null) { gsmTransportInDetails.setComPort((String) transportInDetails.getParameter( SMSTransportConstents.COM_PORT).getValue()); } else { throw new AxisFault("COM PORT NOT SET for the SMS transprot"); } if (transportInDetails.getParameter(SMSTransportConstents.BAUD_RATE) != null) { int bRate = Integer.parseInt((String) transportInDetails.getParameter( SMSTransportConstents.BAUD_RATE).getValue()); gsmTransportInDetails.setBaudRate(bRate); } else { throw new AxisFault("BAUD RATE NOT SET for the SMS transprot"); } if (transportInDetails.getParameter(SMSTransportConstents.MANUFACTURER) != null) { gsmTransportInDetails.setManufacturer((String) transportInDetails.getParameter( SMSTransportConstents.MANUFACTURER).getValue()); } else { throw new AxisFault("Manufactuer NOT SET for the SMS transprot"); } if (transportInDetails.getParameter(SMSTransportConstents.MODEL) != null) { gsmTransportInDetails.setModel((String) transportInDetails.getParameter( SMSTransportConstents.MODEL).getValue()); } else { throw new AxisFault("Model NOT SET for the SMS transprot"); } if (transportInDetails.getParameter(SMSTransportConstents.MODEM_POLL_INTERVAL) != null) { String pollTime = (String) transportInDetails.getParameter(SMSTransportConstents.MODEM_POLL_INTERVAL). getValue(); gsmTransportInDetails.setModemPollInterval(Long.parseLong(pollTime)); } } public void sendSMS(SMSMessage sm) { if (service == null && !serviceRepo.gatewayInUse(gsmTransportOutDetails.getGatewayId())) { //Operating in the Out Only mode service = new Service(); gateway = new SerialModemGateway(gsmTransportOutDetails.getGatewayId(), gsmTransportOutDetails.getComPort(), gsmTransportOutDetails.getBaudRate(), gsmTransportOutDetails.getManufacturer(), gsmTransportOutDetails.getModel()); // Set the modem protocol to PDU (alternative is TEXT). PDU is the default, anyway... gateway.setProtocol(AGateway.Protocols.PDU); // Do we want the Gateway to be used for Outbound messages? gateway.setOutbound(true); // Let SMSLib know which is the SIM PIN. gateway.setSimPin("0000"); try { // Add the Gateway to the Service object. this.service.addGateway(gateway); // Similarly, you may define as many Gateway objects, representing // various GSM modems, add them in the Service object and control all of them. // Start! (i.e. connect to all defined Gateways) this.service.startService(); } catch (Exception e) { log.error(e); } } else if(serviceRepo.gatewayInUse(gsmTransportOutDetails.getGatewayId())) { service = serviceRepo.getService(gsmTransportOutDetails.getGatewayId()); } OutboundMessage msg = new OutboundMessage(sm.getReceiver(), sm.getContent()); try { // a blocking call.This will be blocked untill the message is sent. // normal rate is about 6msgs per minute service.sendMessage(msg); } catch (Exception e) { log.error(e); } } public void setSMSInManager(SMSManager manager) { this.smsInManeger = manager; } public SMSManager getSMSInManager() { return smsInManeger; } }
9,043
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/gsm/GSMTransportOutDetails.java
/* * 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.axis2.transport.sms.gsm; /** * holds the transport out details for the GSM implementation */ public class GSMTransportOutDetails { private static GSMTransportOutDetails ourInstance ; private String gatewayId; private String comPort; private int baudRate; private String manufacturer; private String model; public static GSMTransportOutDetails getInstance() { if(ourInstance == null) { ourInstance = new GSMTransportOutDetails(); } return ourInstance; } private GSMTransportOutDetails() { } public String getGatewayId() { return gatewayId; } public void setGatewayId(String gatewayId) { this.gatewayId = gatewayId; } public String getComPort() { return comPort; } public void setComPort(String comPort) { this.comPort = comPort; } public int getBaudRate() { return baudRate; } public void setBaudRate(int baudRate) { this.baudRate = baudRate; } public String getManufacturer() { return manufacturer; } public void setManufacturer(String manufacturer) { this.manufacturer = manufacturer; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } }
9,044
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/gsm/GSMDispatcher.java
/* * 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.axis2.transport.sms.gsm; import org.smslib.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.ArrayList; import java.util.List; import org.apache.axis2.transport.sms.SMSMessage; import org.apache.axis2.transport.sms.SMSManager; /** * GSMDispatcher will access the gsm modem and dispatch the incomming SMS s to the Axis2 */ public class GSMDispatcher implements Runnable{ protected Log log = LogFactory.getLog(this.getClass()); private boolean keepPolling = true; private Service service; private long pollInterval=5000; private SMSManager smsManager; /** * To create a GSMDispatcher a service object that is created for the current GSM modem is needed * @param service * @param manager */ public GSMDispatcher(Service service , SMSManager manager) { this.service = service; this.smsManager = manager; } public void run() { while(keepPolling) { List<InboundMessage> arrayList = new ArrayList<InboundMessage>(); try { service.readMessages(arrayList, InboundMessage.MessageClasses.UNREAD) ; for(InboundMessage msg : arrayList) { SMSMessage sms =null; synchronized (this) { sms= new SMSMessage(msg.getOriginator(),null,msg.getText() ,SMSMessage.IN_MESSAGE); } smsManager.dispatchToAxis2(sms); //delete the message form inbox service.deleteMessage(msg); } } catch (Exception ex) { log.error("Error Occured while reading messages",ex); } try { Thread.sleep(pollInterval); } catch (InterruptedException e) { } } } public void stopPolling(){ keepPolling = false; } /** * set the modem Polling time * modem polling time will be the time interval that the modem will be polled to get the unread messages * form the inbox. * the optimal value for this will be diffrent form modem to modem. * Keep the default value of you are not aware of it * @param pollInterval */ public void setPollInterval(long pollInterval) { this.pollInterval = pollInterval; } }
9,045
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/gsm/GSMTransportInDetails.java
/* * 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.axis2.transport.sms.gsm; /** * holds the TransportIn details thats needed for the GSM implimentation */ public class GSMTransportInDetails { private static GSMTransportInDetails ourInstance; private String gatewayId; private String comPort; private int baudRate; private String manufacturer; private String model; private long modemPollInterval = 5000; public static GSMTransportInDetails getInstance() { if (ourInstance == null) { ourInstance = new GSMTransportInDetails(); } return ourInstance; } private GSMTransportInDetails() { } public String getGatewayId() { return gatewayId; } public void setGatewayId(String gatewayId) { this.gatewayId = gatewayId; } public String getComPort() { return comPort; } public void setComPort(String comPort) { this.comPort = comPort; } public int getBaudRate() { return baudRate; } public void setBaudRate(int baudRate) { this.baudRate = baudRate; } public String getManufacturer() { return manufacturer; } public void setManufacturer(String manufacturer) { this.manufacturer = manufacturer; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } public long getModemPollInterval() { return modemPollInterval; } public void setModemPollInterval(long modemPollInterval) { this.modemPollInterval = modemPollInterval; } }
9,046
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/gsm/GSMServiceRepository.java
/* * 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.axis2.transport.sms.gsm; import org.smslib.Service; import java.util.Map; import java.util.HashMap; /** * The Repository of started GSM Services * Allow to share and reuse the GSM services */ class GSMServiceRepository { private Map<String, Service> serviceRepo = new HashMap<String,Service>(); private static GSMServiceRepository me; private GSMServiceRepository() { } public static GSMServiceRepository getInstence() { if(me == null) { me = new GSMServiceRepository(); } return me; } /** * add a service with a given gateway * @param gateway * @param service */ public void addService(String gateway , Service service) { if(!gatewayInUse(gateway)) { serviceRepo.put(gateway,service); } } /** * remove the service given the gateway id * @param gateway */ public void removeService(String gateway) { serviceRepo.remove(gateway); } /** * get the service given the gateway id * @param gateway * @return */ public Service getService(String gateway) { return serviceRepo.get(gateway); } /** * to know whether the gateway inuse * @param gateway * @return */ public boolean gatewayInUse(String gateway) { return serviceRepo.containsKey(gateway); } }
9,047
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/smpp/SMPPTransportInDetails.java
/* * 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.axis2.transport.sms.smpp; /** * holds the SMPP imlimantations Transport in details */ public class SMPPTransportInDetails { private String systemType ="cp"; private String systemId; private String password; private String host="127.0.0.1"; private String phoneNumber = "0000"; private int port = 2775; private int enquireLinkTimer = 50000; private int transactionTimer = 100000; private static SMPPTransportInDetails smppTransportInDetails; private SMPPTransportInDetails(){ } public static SMPPTransportInDetails getInstence() { if(smppTransportInDetails == null) { smppTransportInDetails = new SMPPTransportInDetails(); } return smppTransportInDetails; } public String getSystemType() { return systemType; } public void setSystemType(String systemType) { this.systemType = systemType; } public String getSystemId() { return systemId; } public void setSystemId(String systemId) { this.systemId = systemId; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getHost() { return host; } public void setHost(String host) { this.host = host; } public int getPort() { return port; } public void setPort(int port) { this.port = port; } public int getEnquireLinkTimer() { return enquireLinkTimer; } public void setEnquireLinkTimer(int enquireLinkTimer) { this.enquireLinkTimer = enquireLinkTimer; } public int getTransactionTimer() { return transactionTimer; } public void setTransactionTimer(int transactionTimer) { this.transactionTimer = transactionTimer; } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } }
9,048
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/smpp/SimpleSMPPServer.java
/* * 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.axis2.transport.sms.smpp; import org.apache.commons.logging.Log; public class SimpleSMPPServer { /** the reference to the actual commons logger to be used for log messages */ protected Log log = null; public static void main(String[] args) { //to be implemented } }
9,049
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/smpp/SMPPImplManager.java
/* * 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.axis2.transport.sms.smpp; import org.apache.axis2.transport.sms.SMSImplManager; import org.apache.axis2.transport.sms.SMSTransportConstents; import org.apache.axis2.transport.sms.SMSMessage; import org.apache.axis2.transport.sms.SMSManager; import org.apache.axis2.description.TransportInDescription; import org.apache.axis2.description.TransportOutDescription; import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.jsmpp.session.SMPPSession; import org.jsmpp.session.BindParameter; import org.jsmpp.bean.*; import org.jsmpp.util.TimeFormatter; import org.jsmpp.util.AbsoluteTimeFormatter; import org.jsmpp.InvalidResponseException; import org.jsmpp.PDUException; import org.jsmpp.extra.NegativeResponseException; import org.jsmpp.extra.ResponseTimeoutException; import java.io.IOException; import java.util.Date; public class SMPPImplManager implements SMSImplManager { /** the reference to the actual commons logger to be used for log messages */ protected Log log = LogFactory.getLog(this.getClass()); private SMPPTransportInDetails smppTransportInDetails = SMPPTransportInDetails.getInstence(); private SMPPTransportOutDetails smppTransportOutDetails = SMPPTransportOutDetails.getInstence(); private volatile boolean stop=true; private SMSManager smsInManeger; private SMPPSession inSession; private SMPPSession outSession; private static TimeFormatter timeFormatter = new AbsoluteTimeFormatter(); /** * SMPP implementation Constents */ public static String SOURCE_ADDRESS_TON = "source_address_ton"; public static String SOURCE_ADDRESS_NPI = "source_address_npi"; public static String DESTINATION_ADDRESS_TON = "destination_address_ton"; public static String DESTINATION_ADDRESS_NPI = "destination_address_npi"; public void start() { inSession = new SMPPSession(); try { inSession.connectAndBind(smppTransportInDetails.getHost(), smppTransportInDetails.getPort(), new BindParameter(BindType.BIND_RX, smppTransportInDetails.getSystemId(), smppTransportInDetails.getPassword(), smppTransportInDetails.getSystemType() , TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, null)); SMPPListener listener = new SMPPListener(smsInManeger); inSession.setMessageReceiverListener(listener); stop = false; System.out.println(" [Axis2] bind and connect to " + smppTransportInDetails.getHost()+" : " + smppTransportInDetails.getPort() + " on SMPP Transport"); } catch (IOException e) { log.error("Unable to conncet" + e); } } public void stop() { log.info("Stopping SMPP Transport ..."); stop = true; if(inSession != null) { inSession.unbindAndClose(); } if(outSession !=null) { outSession.unbindAndClose(); } } public void setTransportInDetails(TransportInDescription transportInDetails) throws AxisFault { if(transportInDetails == null) { throw new AxisFault("No transport in details"); } if(transportInDetails.getParameter(SMSTransportConstents.SYSTEM_TYPE) != null){ smppTransportInDetails.setSystemType((String)transportInDetails.getParameter( SMSTransportConstents.SYSTEM_TYPE).getValue()); } if (transportInDetails.getParameter(SMSTransportConstents.SYSTEM_ID) != null) { smppTransportInDetails.setSystemId((String)transportInDetails.getParameter(SMSTransportConstents.SYSTEM_ID). getValue()); } else { throw new AxisFault("System Id not set"); } if (transportInDetails.getParameter(SMSTransportConstents.PASSWORD) != null) { smppTransportInDetails.setPassword((String)transportInDetails.getParameter(SMSTransportConstents.PASSWORD). getValue()); } else { throw new AxisFault("password not set"); } if(transportInDetails.getParameter(SMSTransportConstents.HOST) != null) { smppTransportInDetails.setHost((String)transportInDetails.getParameter(SMSTransportConstents.HOST). getValue()); } if(transportInDetails.getParameter(SMSTransportConstents.PORT) != null) { smppTransportInDetails.setPort(Integer.parseInt((String)transportInDetails.getParameter( SMSTransportConstents.PORT).getValue())); } if(transportInDetails.getParameter(SMSTransportConstents.PHONE_NUMBER) != null) { smppTransportInDetails.setPhoneNumber((String)transportInDetails.getParameter( SMSTransportConstents.PHONE_NUMBER).getValue()); } } public void setTransportOutDetails(TransportOutDescription transportOutDetails) throws AxisFault{ if(transportOutDetails == null) { throw new AxisFault("No transport in details"); } if(transportOutDetails.getParameter(SMSTransportConstents.SYSTEM_TYPE) != null){ smppTransportOutDetails.setSystemType((String)transportOutDetails.getParameter( SMSTransportConstents.SYSTEM_TYPE).getValue()); } if (transportOutDetails.getParameter(SMSTransportConstents.SYSTEM_ID) != null) { smppTransportOutDetails.setSystemId((String)transportOutDetails.getParameter(SMSTransportConstents.SYSTEM_ID). getValue()); } else { throw new AxisFault("System Id not set"); } if (transportOutDetails.getParameter(SMSTransportConstents.PASSWORD) != null) { smppTransportOutDetails.setPassword((String)transportOutDetails.getParameter(SMSTransportConstents.PASSWORD). getValue()); } else { throw new AxisFault("password not set"); } if(transportOutDetails.getParameter(SMSTransportConstents.HOST) != null) { smppTransportOutDetails.setHost((String)transportOutDetails.getParameter(SMSTransportConstents.HOST). getValue()); } if(transportOutDetails.getParameter(SMSTransportConstents.PORT) != null) { smppTransportOutDetails.setPort(Integer.parseInt((String)transportOutDetails.getParameter( SMSTransportConstents.PORT).getValue())); } if(transportOutDetails.getParameter(SMSTransportConstents.PHONE_NUMBER) != null) { smppTransportOutDetails.setPhoneNumber((String)transportOutDetails.getParameter( SMSTransportConstents.PHONE_NUMBER).getValue()); } } public void sendSMS(SMSMessage sm) { TypeOfNumber sourceTon =TypeOfNumber.UNKNOWN; NumberingPlanIndicator sourceNpi = NumberingPlanIndicator.UNKNOWN; TypeOfNumber destTon = TypeOfNumber.UNKNOWN; NumberingPlanIndicator destNpi = NumberingPlanIndicator.UNKNOWN; try { if (outSession == null) { outSession = new SMPPSession(); outSession.setEnquireLinkTimer(smppTransportOutDetails.getEnquireLinkTimer()); outSession.setTransactionTimer(smppTransportOutDetails.getTransactionTimer()); outSession.connectAndBind(smppTransportOutDetails.getHost(), smppTransportOutDetails.getPort(), new BindParameter(BindType.BIND_TX, smppTransportOutDetails.getSystemId(), smppTransportOutDetails.getPassword(), smppTransportOutDetails.getSystemType(), TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, null)); log.debug("Conected and bind to " + smppTransportOutDetails.getHost()); } boolean invert = true; if("false".equals(sm.getProperties().get(SMSTransportConstents.INVERT_SOURCE_AND_DESTINATION))){ invert = false; } if(invert) { if(sm.getProperties().get(DESTINATION_ADDRESS_NPI) != null) { sourceNpi = NumberingPlanIndicator.valueOf((String)sm.getProperties().get(DESTINATION_ADDRESS_NPI)); } if(sm.getProperties().get(DESTINATION_ADDRESS_TON) != null) { sourceTon = TypeOfNumber.valueOf((String)sm.getProperties().get(DESTINATION_ADDRESS_TON)); } if(sm.getProperties().get(SOURCE_ADDRESS_NPI) != null) { destNpi = NumberingPlanIndicator.valueOf((String)sm.getProperties().get(SOURCE_ADDRESS_NPI)); } if(sm.getProperties().get(SOURCE_ADDRESS_TON) != null) { destTon = TypeOfNumber.valueOf((String)sm.getProperties().get(SOURCE_ADDRESS_TON)); } } else { if(sm.getProperties().get(DESTINATION_ADDRESS_NPI) != null) { destNpi = NumberingPlanIndicator.valueOf((String)sm.getProperties().get(DESTINATION_ADDRESS_NPI)); } if(sm.getProperties().get(DESTINATION_ADDRESS_TON) != null) { destTon = TypeOfNumber.valueOf((String)sm.getProperties().get(DESTINATION_ADDRESS_TON)); } if(sm.getProperties().get(SOURCE_ADDRESS_NPI) != null) { sourceNpi = NumberingPlanIndicator.valueOf((String)sm.getProperties().get(SOURCE_ADDRESS_NPI)); } if(sm.getProperties().get(SOURCE_ADDRESS_TON) != null) { sourceTon = TypeOfNumber.valueOf((String)sm.getProperties().get(SOURCE_ADDRESS_TON)); } } String messageId = outSession.submitShortMessage( "CMT", sourceTon, sourceNpi, sm.getSender(), destTon, destNpi, sm.getReceiver(), new ESMClass(), (byte) 0, (byte) 1, timeFormatter.format(new Date()), null, new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte) 0, new GeneralDataCoding(false, false, MessageClass.CLASS1,Alphabet.ALPHA_DEFAULT), (byte) 0, sm.getContent().getBytes() ); log.debug("Message Submited with id" + messageId); } catch (IOException e) { log.error("Unable to Connect ", e); } catch (InvalidResponseException e) { log.debug("Invalid responce Exception", e); } catch (PDUException e) { log.debug("PDU Exception", e); } catch (NegativeResponseException e) { log.debug(e); } catch (ResponseTimeoutException e) { log.debug(e); } } public void setSMSInManager(SMSManager manager) { this.smsInManeger = manager; } public SMSManager getSMSInManager() { return smsInManeger; } }
9,050
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/smpp/SMPPMessage.java
/* * 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.axis2.transport.sms.smpp; import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * SMPP message is a atomic object wich carries a SMPPMessage */ public class SMPPMessage { private String sender; private String receiver; private String content; private int direction; public static int IN_MESSAGE =1; public static int OUT_MESSAGE =2; public SMPPMessage(String sender ,String reciever, String content , int direction) throws AxisFault { this.sender = sender; this.content = content; this.receiver = reciever; if (direction == IN_MESSAGE || direction == OUT_MESSAGE ) { this.direction = direction; } else { throw new AxisFault("Message must be in or out"); } } public String getSender() { return sender; } public String getReceiver() { return receiver; } public String getContent() { return content; } public int getDirection() { return direction; } }
9,051
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/smpp/SMPPTransportOutDetails.java
/* * 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.axis2.transport.sms.smpp; /** * Holds the SMPP implimantations transport out details */ public class SMPPTransportOutDetails { //smpp system type private String systemType ="cp"; private String systemId; private String password; private String host="127.0.0.1"; private String phoneNumber="0000"; private int port = 2775; private int enquireLinkTimer = 50000; private int transactionTimer = 100000; private static SMPPTransportOutDetails smppTransportOutDetails; private SMPPTransportOutDetails(){ } /** * Get the referrence to the Singleton instence of the SMPP Transport Out details * at the first request it will create a empty object * @return SMPPTransportOutDetails instence */ public static SMPPTransportOutDetails getInstence() { if(smppTransportOutDetails ==null) { smppTransportOutDetails = new SMPPTransportOutDetails(); } return smppTransportOutDetails; } public int getTransactionTimer() { return transactionTimer; } public void setTransactionTimer(int transactionTimer) { this.transactionTimer = transactionTimer; } public int getEnquireLinkTimer() { return enquireLinkTimer; } public void setEnquireLinkTimer(int enquireLinkTimer) { this.enquireLinkTimer = enquireLinkTimer; } public int getPort() { return port; } public void setPort(int port) { this.port = port; } public String getHost() { return host; } public void setHost(String host) { this.host = host; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getSystemId() { return systemId; } public void setSystemId(String systemId) { this.systemId = systemId; } public String getSystemType() { return systemType; } public void setSystemType(String systemType) { this.systemType = systemType; } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } @Override public String toString() { return "TransportOutDetails:: SystemId: " +systemId +" systemType: "+ systemType + " password: " +password+" host: "+host+" port: " +port+" phone NUmber" + phoneNumber; } }
9,052
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/smpp/SMPPListener.java
/* * 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.axis2.transport.sms.smpp; import org.jsmpp.bean.*; import org.jsmpp.extra.ProcessRequestException; import org.jsmpp.session.DataSmResult; import org.jsmpp.session.MessageReceiverListener; import org.jsmpp.util.InvalidDeliveryReceiptException; import org.apache.axis2.AxisFault; import org.apache.axis2.transport.sms.SMSManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import java.util.HashMap; import java.util.Map; /** * Listen for the incomming SMPP messages and Start processing them */ public class SMPPListener implements MessageReceiverListener{ /** the reference to the actual commons logger to be used for log messages */ protected Log log = LogFactory.getLog(this.getClass()); private SMSManager smsManeger; public SMPPListener(SMSManager manager){ this.smsManeger = manager; } public void onAcceptDeliverSm(DeliverSm deliverSm) throws ProcessRequestException { if (MessageType.SMSC_DEL_RECEIPT.containedIn(deliverSm.getEsmClass())) { // this message is delivery receipt try { DeliveryReceipt delReceipt = deliverSm.getShortMessageAsDeliveryReceipt(); // lets cover the id to hex string format long id = Long.parseLong(delReceipt.getId()) & 0xffffffff; String messageId = Long.toString(id, 16).toUpperCase(); /* * you can update the status of your submitted message on the * database based on messageId */ log.debug("Receiving delivery receipt for message '" + messageId + " ' from " + deliverSm.getSourceAddr() + " to " + deliverSm.getDestAddress() + " : " + delReceipt); } catch (InvalidDeliveryReceiptException e) { log.debug("Failed getting delivery receipt" , e); } } else { Map<String , Object> properties = new HashMap<String,Object>(); properties.put(SMPPImplManager.SOURCE_ADDRESS_TON , TypeOfNumber.valueOf(deliverSm.getSourceAddrTon()).toString()); properties.put(SMPPImplManager.SOURCE_ADDRESS_NPI , NumberingPlanIndicator.valueOf(deliverSm.getSourceAddrNpi()).toString()); properties.put(SMPPImplManager.DESTINATION_ADDRESS_TON , TypeOfNumber.valueOf(deliverSm.getDestAddrTon()).toString()); properties.put(SMPPImplManager.DESTINATION_ADDRESS_NPI , NumberingPlanIndicator.valueOf(deliverSm.getDestAddrNpi()).toString()); try { new SMPPDispatcher(smsManeger).dispatch(deliverSm.getSourceAddr() ,deliverSm.getDestAddress() , new String(deliverSm.getShortMessage()), properties); } catch (AxisFault axisFault) { log.debug("Error while dispatching SMPP message" , axisFault); } log.debug("Receiving message : " + new String(deliverSm.getShortMessage())); } } public void onAcceptAlertNotification(AlertNotification alertNotification) { } public DataSmResult onAcceptDataSm(DataSm dataSm) throws ProcessRequestException { return null; } }
9,053
0
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms
Create_ds/axis-axis2-java-transports/modules/sms/src/main/java/org/apache/axis2/transport/sms/smpp/SMPPDispatcher.java
/* * 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.axis2.transport.sms.smpp; import org.apache.axis2.AxisFault; import org.apache.axis2.transport.sms.SMSManager; import org.apache.axis2.transport.sms.SMSMessage; import java.util.Map; /** * Dispatch the SMS message taken frpm the SMPP PDU to the Axis2 */ public class SMPPDispatcher{ SMSMessage smsMessage; private SMSManager manager; public SMPPDispatcher(SMSManager manager) { this.manager = manager; } void dispatch(String source , String receiver,String message , Map<String , Object> properties) throws AxisFault { synchronized (this){ smsMessage = new SMSMessage(source ,receiver, message , SMSMessage.IN_MESSAGE); smsMessage.getProperties().putAll(properties); } manager.dispatchToAxis2(smsMessage); } }
9,054
0
Create_ds/atlas/atlas-core/src/test/java/com/netflix/atlas/core
Create_ds/atlas/atlas-core/src/test/java/com/netflix/atlas/core/validation/JavaTestRule.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.core.validation; import com.typesafe.config.Config; public class JavaTestRule extends TagRuleWrapper { public JavaTestRule(Config conf) { } @Override public String validate(String k, String v) { return null; } }
9,055
0
Create_ds/atlas/atlas-core/src/main/scala/com/netflix/atlas/core
Create_ds/atlas/atlas-core/src/main/scala/com/netflix/atlas/core/util/PrimeFinder.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.core.util; import java.util.Arrays; /** * Copied from the apache-mahout project. * * <p>Not of interest for users; only for implementors of hashtables. * Used to keep hash table capacities prime numbers. * * <p>Choosing prime numbers as hash table capacities is a good idea to keep them working fast, * particularly under hash table expansions. * * <p>However, JDK 1.2, JGL 3.1 and many other toolkits do nothing to keep capacities prime. * This class provides efficient means to choose prime capacities. * * <p>Choosing a prime is <tt>O(log 300)</tt> (binary search in a list of 300 int's). * Memory requirements: 1 KB static memory. * */ class PrimeFinder { /** The largest prime this class can generate; currently equal to <tt>Integer.MAX_VALUE</tt>. */ public static final int largestPrime = Integer.MAX_VALUE; //yes, it is prime. /** * The prime number list consists of 11 chunks. Each chunk contains prime numbers. A chunk starts with a prime P1. The * next element is a prime P2. P2 is the smallest prime for which holds: P2 >= 2*P1. The next element is P3, for which * the same holds with respect to P2, and so on. * * <p>Chunks are chosen such that for any desired capacity >= 1000 the list includes a prime number <= desired capacity * * 1.11 (11%). For any desired capacity >= 200 the list includes a prime number <= desired capacity * 1.16 (16%). For * any desired capacity >= 16 the list includes a prime number <= desired capacity * 1.21 (21%). * * <p>Therefore, primes can be retrieved which are quite close to any desired capacity, which in turn avoids wasting * memory. For example, the list includes 1039,1117,1201,1277,1361,1439,1523,1597,1759,1907,2081. So if you need a * prime >= 1040, you will find a prime <= 1040*1.11=1154. * * <p>Chunks are chosen such that they are optimized for a hashtable growthfactor of 2.0; If your hashtable has such a * growthfactor then, after initially "rounding to a prime" upon hashtable construction, it will later expand to prime * capacities such that there exist no better primes. * * <p>In total these are about 32*10=320 numbers -> 1 KB of static memory needed. If you are stingy, then delete every * second or fourth chunk. */ private static final int[] primeCapacities = { //chunk #0 largestPrime, //chunk #1 5, 11, 23, 47, 97, 197, 397, 797, 1597, 3203, 6421, 12853, 25717, 51437, 102877, 205759, 411527, 823117, 1646237, 3292489, 6584983, 13169977, 26339969, 52679969, 105359939, 210719881, 421439783, 842879579, 1685759167, //chunk #2 433, 877, 1759, 3527, 7057, 14143, 28289, 56591, 113189, 226379, 452759, 905551, 1811107, 3622219, 7244441, 14488931, 28977863, 57955739, 115911563, 231823147, 463646329, 927292699, 1854585413, //chunk #3 953, 1907, 3821, 7643, 15287, 30577, 61169, 122347, 244703, 489407, 978821, 1957651, 3915341, 7830701, 15661423, 31322867, 62645741, 125291483, 250582987, 501165979, 1002331963, 2004663929, //chunk #4 1039, 2081, 4177, 8363, 16729, 33461, 66923, 133853, 267713, 535481, 1070981, 2141977, 4283963, 8567929, 17135863, 34271747, 68543509, 137087021, 274174111, 548348231, 1096696463, //chunk #5 31, 67, 137, 277, 557, 1117, 2237, 4481, 8963, 17929, 35863, 71741, 143483, 286973, 573953, 1147921, 2295859, 4591721, 9183457, 18366923, 36733847, 73467739, 146935499, 293871013, 587742049, 1175484103, //chunk #6 599, 1201, 2411, 4831, 9677, 19373, 38747, 77509, 155027, 310081, 620171, 1240361, 2480729, 4961459, 9922933, 19845871, 39691759, 79383533, 158767069, 317534141, 635068283, 1270136683, //chunk #7 311, 631, 1277, 2557, 5119, 10243, 20507, 41017, 82037, 164089, 328213, 656429, 1312867, 2625761, 5251529, 10503061, 21006137, 42012281, 84024581, 168049163, 336098327, 672196673, 1344393353, //chunk #8 3, 7, 17, 37, 79, 163, 331, 673, 1361, 2729, 5471, 10949, 21911, 43853, 87719, 175447, 350899, 701819, 1403641, 2807303, 5614657, 11229331, 22458671, 44917381, 89834777, 179669557, 359339171, 718678369, 1437356741, //chunk #9 43, 89, 179, 359, 719, 1439, 2879, 5779, 11579, 23159, 46327, 92657, 185323, 370661, 741337, 1482707, 2965421, 5930887, 11861791, 23723597, 47447201, 94894427, 189788857, 379577741, 759155483, 1518310967, //chunk #10 379, 761, 1523, 3049, 6101, 12203, 24407, 48817, 97649, 195311, 390647, 781301, 1562611, 3125257, 6250537, 12501169, 25002389, 50004791, 100009607, 200019221, 400038451, 800076929, 1600153859 }; static { //initializer // The above prime numbers are formatted for human readability. // To find numbers fast, we sort them once and for all. Arrays.sort(primeCapacities); } /** Makes this class non instantiable, but still let's others inherit from it. */ private PrimeFinder() { } /** * Returns a prime number which is <code>&gt;= desiredCapacity</code> and very close to <code>desiredCapacity</code> * (within 11% if <code>desiredCapacity &gt;= 1000</code>). * * @param desiredCapacity the capacity desired by the user. * @return the capacity which should be used for a hashtable. */ public static int nextPrime(int desiredCapacity) { int i = java.util.Arrays.binarySearch(primeCapacities, desiredCapacity); if (i < 0) { // desired capacity not found, choose next prime greater than desired capacity i = -i - 1; // remember the semantics of binarySearch... } return primeCapacities[i]; } }
9,056
0
Create_ds/atlas/atlas-core/src/main/scala/com/netflix/atlas/core
Create_ds/atlas/atlas-core/src/main/scala/com/netflix/atlas/core/util/Features.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.core.util; /** * Set of features that are enabled for the API. */ public enum Features { /** Default feature set that is stable and the user can rely on. */ STABLE, /** * Indicates that unstable features should be enabled for testing by early adopters. * Features in this set can change at anytime without notice. A feature should not stay * in this state for a long time. A few months should be considered an upper bound. */ UNSTABLE }
9,057
0
Create_ds/atlas/atlas-eval/src/main/scala/com/netflix/atlas/eval
Create_ds/atlas/atlas-eval/src/main/scala/com/netflix/atlas/eval/stream/Evaluator.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.eval.stream; import org.apache.pekko.actor.ActorSystem; import org.apache.pekko.http.javadsl.model.Uri; import org.apache.pekko.stream.Materializer; import org.apache.pekko.stream.ThrottleMode; import org.apache.pekko.stream.javadsl.Flow; import org.apache.pekko.stream.javadsl.Framing; import org.apache.pekko.stream.javadsl.Source; import org.apache.pekko.stream.javadsl.StreamConverters; import org.apache.pekko.util.ByteString; import com.fasterxml.jackson.annotation.JsonIgnore; import com.netflix.atlas.core.util.Strings$; import com.netflix.atlas.json.JsonSupport; import com.netflix.spectator.api.NoopRegistry; import com.netflix.spectator.api.Registry; import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import org.reactivestreams.Processor; import org.reactivestreams.Publisher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; /** * Public API for streaming evaluation of expressions. */ public final class Evaluator extends EvaluatorImpl { /** * Create a new instance. It is assumed this is created via the injector and the * signature may change over time. */ public Evaluator(Config config, Registry registry, ActorSystem system) { super(config, registry, system, Materializer.createMaterializer(system)); } /** * Collects the data from LWC for the specified duration and store it to a file. The * file can then be used as an input to replay evaluation. * * @param uri * Source URI for collecting the data. * @param file * Output file to store the results. * @param duration * Specified how long the collection will run. Note this method will block until * the collection is complete. */ public void writeInputToFile(String uri, Path file, Duration duration) { writeInputToFileImpl(uri, file, duration); } /** * Creates a publisher stream for a given URI. * * @param uri * Source URI for collecting the data. * @return * Publisher that produces events representing the evaluation results for the * expression in the URI. */ public Publisher<JsonSupport> createPublisher(String uri) { return createPublisherImpl(uri); } /** * Creates a processor that can multiplex many streams at once. This can be used to * help reduce the overhead in terms of number of connections and duplicate work on * the backend producing the data. * * <p>It takes a stream of data sources as an input and returns the output of evaluating * those streams. Each {@code DataSources} object should be the complete set of * sources that should be evaluated at a given time. The output messages can be * correlated with a particular data source using the id on the {@code MessageEnvelope}. */ public Processor<DataSources, MessageEnvelope> createStreamsProcessor() { return createStreamsProcessorImpl(); } /** * Creates a processor that evaluates a fixed set of expressions against the stream of * time grouped datapoints. The caller must ensure: * * <ul> * <li>All data sources have the same step size. This is required because there is a * single input datapoint stream with a fixed step.</li> * <li>There should be a single group for each step interval with timestamps aligned to * the step boundary.</li> * <li>Operations are feasible for the input. Time based operators may or may not work * correctly depending on how the timestamps for the input groups are determined. * For use-cases where the the timestamps are generated arbitrarily, such as incrementing * for each group once a certain number of datapoints is available, then operators * based on a clock such as {@code :time} will have bogus values based on the arbitrary * times for the group. If the data is a snapshot of an actual stream, then time based * operators should work correctly.</li> * </ul> */ public Processor<DatapointGroup, MessageEnvelope> createDatapointProcessor(DataSources sources) { return createDatapointProcessorImpl(sources); } /** * Perform static analysis checks to ensure that the provided data source is supported * by this evaluator instance. * * @param ds * Data source to validate. */ public void validate(DataSource ds) { validateImpl(ds); } /** * Immutable set of data sources that should be consumed. */ public record DataSources(Set<DataSource> sources) { /** Create a new instance that is empty. */ public static DataSources empty() { return new DataSources(Collections.emptySet()); } /** Create a new instance. */ public static DataSources of(DataSource... sources) { Set<DataSource> set = new HashSet<>(Arrays.asList(sources)); return new DataSources(set); } /** Create a new instance. */ public DataSources { sources = Set.copyOf(sources); } /** Compares with another set and returns the new data sources that have been added. */ public Set<DataSource> addedSources(DataSources other) { Set<DataSource> copy = new HashSet<>(sources); copy.removeAll(other.sources()); return copy; } /** Compares with another set and returns the data sources that have been removed. */ public Set<DataSource> removedSources(DataSources other) { return other.addedSources(this); } DataSources remoteOnly() { Set<DataSource> remote = new HashSet<>(sources); remote.removeAll(localSources()); return new DataSources(remote); } DataSources localOnly() { return new DataSources(localSources()); } private Set<DataSource> localSources() { return sources.stream() .filter(DataSource::isLocal) .collect(Collectors.toSet()); } /** * Return the step size for the sources in this set. If there are mixed step sizes an * IllegalStateException will be thrown. If the set is empty, then -1 will be returned. */ long stepSize() { long step = -1L; for (DataSource source : sources) { long sourceStep = source.step().toMillis(); if (step != -1L && step != sourceStep) { throw new IllegalStateException("inconsistent step sizes, expected " + step + ", found " + sourceStep + " on " + source); } step = sourceStep; } return step; } } /** * Triple mapping an id to a step size and a URI that should be consumed. The * id can be used to find the messages in the output that correspond to this * data source. * * @param id * An identifier for this {@code DataSource}. It will be added to * corresponding MessageEnvelope objects in the output, facilitating * matching output messages with the data source. * @param step * The requested step size for this {@code DataSource}. <em>NOTE:</em> * This may result in rejection of this {@code DataSource} if the * backing metrics producers do not support the requested step size. * @param uri * The URI for this {@code DataSource} (in atlas backend form). */ public record DataSource(String id, Duration step, String uri) { /** * Create a new instance. */ public DataSource { step = step == null ? extractStepFromUri(uri) : step; } /** * Create a new instance with the step size being derived from the URI or falling * back to {@link #DEFAULT_STEP}. * * @param id * An identifier for this {@code DataSource}. It will be added to * corresponding MessageEnvelope objects in the output, facilitating * matching output messages with the data source. * @param uri * The URI for this {@code DataSource} (in atlas backend form). */ public DataSource(String id, String uri) { this(id, null, uri); } /** Returns true if the URI is for a local file or classpath resource. */ @JsonIgnore public boolean isLocal() { return uri.startsWith("/") || uri.startsWith("file:") || uri.startsWith("resource:") || uri.startsWith("synthetic:"); } } /** * Wraps the output messages from the evaluation with the id of the data source. This * can be used to route the message back to the appropriate consumer. */ public record MessageEnvelope(String id, JsonSupport message) { } /** * Group of datapoints for the same time. */ public record DatapointGroup(long timestamp, List<Datapoint> datapoints) { } /** * Represents a datapoint for a dataset that is generated independently of the LWC clusters. * This can be used for synthetic data or if there is an alternative data source such as a * stream of events that are being mapped into streaming time series. */ public record Datapoint(Map<String, String> tags, double value) { } /** The default step size. */ private static final Duration DEFAULT_STEP = Duration.ofSeconds(60L); /** * Try to extract the step size based on the URI query parameter. If this fails for any * reason or the parameter is not present, then use the default of 1 minute. */ private static Duration extractStepFromUri(String uriString) { try { Uri uri = Uri.create(uriString, Uri.RELAXED); return uri.query() .get("step") .map(Strings$.MODULE$::parseDuration) .orElse(DEFAULT_STEP); } catch (Exception e) { return DEFAULT_STEP; } } /** * Helper used for simple tests. A set of URIs will be read from {@code stdin}, one per line, * and sent through a processor created via {@link #createStreamsProcessor()}. The output will * be sent to {@code stdout}. * * @param args * Paths to additional configuration files that should be loaded. The configs will be * loaded in order with later entries overriding earlier ones if there are conflicts. */ public static void main(String[] args) throws Exception { final Logger logger = LoggerFactory.getLogger(Evaluator.class); // Load any additional configurations if present Config config = ConfigFactory.load(); for (String file : args) { logger.info("loading configuration file {}", file); config = ConfigFactory.parseFile(new File(file)) .withFallback(config) .resolve(); } // Setup evaluator ActorSystem system = ActorSystem.create(); Materializer mat = Materializer.createMaterializer(system); Evaluator evaluator = new Evaluator(config, new NoopRegistry(), system); // Process URIs StreamConverters // Read in URIs from stdin .fromInputStream(() -> System.in) .via(Framing.delimiter(ByteString.fromString("\n"), 16384)) .map(b -> b.decodeString(StandardCharsets.UTF_8)) .zipWithIndex() // Use line number as id for output .map(p -> new DataSource(p.second().toString(), p.first())) .fold(new HashSet<DataSource>(), (vs, v) -> { vs.add(v); return vs; }) .map(DataSources::new) .flatMapConcat(Source::repeat) // Repeat so stream doesn't shutdown .throttle( // Throttle to avoid wasting CPU 1, Duration.ofMinutes(1), 1, ThrottleMode.shaping() ) .via(Flow.fromProcessor(evaluator::createStreamsProcessor)) .runForeach( msg -> System.out.printf("%10s: %s%n", msg.id(), msg.message().toJson()), mat ) .toCompletableFuture() .get(); } }
9,058
0
Create_ds/atlas/atlas-eval/src/main/scala/com/netflix/atlas/eval
Create_ds/atlas/atlas-eval/src/main/scala/com/netflix/atlas/eval/model/ExprType.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.eval.model; /** Indicates the type of expression for a subscription. */ public enum ExprType { /** * Time series expression such as used with Atlas Graph API. Can also be used for analytics * queries on top of event data. */ TIME_SERIES, /** Expression to select a set of events to be passed through. */ EVENTS, /** Expression to select a set of traces to be passed through. */ TRACES }
9,059
0
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart/model/VisionType.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.chart.model; import java.awt.Color; /** * Convert a color to simulate a type of color blindness for those with normal vision. Based on: * <a href="http://web.archive.org/web/20081014161121/http://www.colorjack.com/labs/colormatrix/">colormatrix</a>. */ public enum VisionType { normal(new double[] { 1.000, 0.000, 0.000, 0.000, // R 0.000, 1.000, 0.000, 0.000, // G 0.000, 0.000, 1.000, 0.000, // B 0.000, 0.000, 0.000, 1.000 // A }), protanopia(new double[] { 0.567, 0.433, 0.000, 0.000, // R 0.558, 0.442, 0.000, 0.000, // G 0.000, 0.242, 0.758, 0.000, // B 0.000, 0.000, 0.000, 1.000 // A }), protanomaly(new double[] { 0.817, 0.183, 0.000, 0.000, // R 0.333, 0.667, 0.000, 0.000, // G 0.000, 0.125, 0.875, 0.000, // B 0.000, 0.000, 0.000, 1.000 // A }), deuteranopia(new double[] { 0.625, 0.375, 0.000, 0.000, // R 0.700, 0.300, 0.000, 0.000, // G 0.000, 0.300, 0.700, 0.000, // B 0.000, 0.000, 0.000, 1.000 // A }), deuteranomaly(new double[] { 0.800, 0.200, 0.000, 0.000, // R 0.258, 0.742, 0.000, 0.000, // G 0.000, 0.142, 0.858, 0.000, // B 0.000, 0.000, 0.000, 1.000 // A }), tritanopia(new double[] { 0.950, 0.050, 0.000, 0.000, // R 0.000, 0.433, 0.567, 0.000, // G 0.000, 0.475, 0.525, 0.000, // B 0.000, 0.000, 0.000, 1.000 // A }), tritanomaly(new double[] { 0.967, 0.033, 0.000, 0.000, // R 0.000, 0.733, 0.267, 0.000, // G 0.000, 0.183, 0.817, 0.000, // B 0.000, 0.000, 0.000, 1.000 // A }), achromatopsia(new double[] { 0.299, 0.587, 0.114, 0.000, // R 0.299, 0.587, 0.114, 0.000, // G 0.299, 0.587, 0.114, 0.000, // B 0.000, 0.000, 0.000, 1.000 // A }), achromatomaly(new double[] { 0.618, 0.320, 0.062, 0.000, // R 0.163, 0.775, 0.062, 0.000, // G 0.163, 0.320, 0.516, 0.000, // B 0.000, 0.000, 0.000, 1.000 // A }); private final double[] m; VisionType(double[] m) { this.m = m; } public Color convert(Color c) { final int cr = c.getRed(); final int cg = c.getGreen(); final int cb = c.getBlue(); final int ca = c.getAlpha(); final int br = (int) (cr * m[0] + cg * m[1] + cb * m[2] + ca * m[3]); final int bg = (int) (cr * m[4] + cg * m[5] + cb * m[6] + ca * m[7]); final int bb = (int) (cr * m[8] + cg * m[9] + cb * m[10] + ca * m[11]); final int ba = (int) (cr * m[12] + cg * m[13] + cb * m[14] + ca * m[15]); return new Color(br, bg, bb, ba); } }
9,060
0
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart/model/Layout.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.chart.model; /** * Layout mode to use for the chart. */ public enum Layout { /** * Size is specified for the canvas showing the data and the image size is determined * automatically. This mode is the default and is intended to make it easy to get a consistent * canvas size for a set of charts. */ CANVAS(false, false), /** * Size is specified for the image. Other elements will resize or shut off to fit within the * requested size. */ IMAGE(true, true), /** * Width is for the image, but height is for the canvas. This can be useful for pages that * need to perform column spans for some rows. The height will be automatically determined. */ IMAGE_WIDTH(true, false), /** * Height is for the image, but width is for the canvas. */ IMAGE_HEIGHT(false, true); private final boolean fixedWidth; private final boolean fixedHeight; Layout(boolean fixedWidth, boolean fixedHeight) { this.fixedWidth = fixedWidth; this.fixedHeight = fixedHeight; } public boolean isFixedWidth() { return fixedWidth; } public boolean isFixedHeight() { return fixedHeight; } public static Layout create(String name) { return switch (name) { case "canvas" -> Layout.CANVAS; case "image" -> Layout.IMAGE; case "iw" -> Layout.IMAGE_WIDTH; case "ih" -> Layout.IMAGE_HEIGHT; default -> throw new IllegalArgumentException("unknown layout: " + name); }; } }
9,061
0
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart/model/TickLabelMode.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.chart.model; import java.util.Locale; /** * Mode for how to format the tick labels on Y-axes. */ public enum TickLabelMode { /** * Do no show tick labels. It can be useful to suppress the labels for including the charts * in presentations or support tickets where it is not desirable to share the exact numbers. */ OFF, /** * Use decimal <a href="https://en.wikipedia.org/wiki/Metric_prefix">metric prefixes</a> for * tick labels. */ DECIMAL, /** * Use <a href="https://en.wikipedia.org/wiki/Binary_prefix">binary prefixes</a> for tick * labels. Typically only used for data in bytes such as disk sizes. */ BINARY, /** * Use SI for durations less than a second and 's', 'min', 'hr', 'day', 'mon', 'yr' over that. */ DURATION; /** * Case insensitive conversion of a string name to an enum value. */ public static TickLabelMode apply(String mode) { try { return valueOf(mode.toUpperCase(Locale.US)); } catch (IllegalArgumentException e) { // Make the error message a bit more user friendly throw new IllegalArgumentException("tick_labels: unknown value '" + mode + "', acceptable values are off, decimal, and binary"); } } }
9,062
0
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart/model/LineStyle.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.chart.model; /** * Line styles for how to render an time series. */ public enum LineStyle { LINE, AREA, STACK, VSPAN, HEATMAP }
9,063
0
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart/model/Scale.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.chart.model; /** * Type of scale to use for mapping raw input values into y-coordinates on the chart. */ public enum Scale { LINEAR, LOGARITHMIC, LOG_LINEAR, POWER_2, SQRT; /** Returns the scale constant associated with a given name. */ public static Scale fromName(String s) { return switch (s) { case "linear" -> LINEAR; case "log" -> LOGARITHMIC; case "log-linear" -> LOG_LINEAR; case "pow2" -> POWER_2; case "sqrt" -> SQRT; default -> throw new IllegalArgumentException("unknown scale type '" + s + "', should be linear, log, log-linear, pow2, or sqrt"); }; } }
9,064
0
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart/model/LegendType.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.chart.model; /** * Mode for the legend. */ public enum LegendType { OFF, LABELS_ONLY, LABELS_WITH_STATS }
9,065
0
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart
Create_ds/atlas/atlas-chart/src/main/scala/com/netflix/atlas/chart/graphics/TextAlignment.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.chart.graphics; /** * How to align text when wrapping to fit a display width. */ public enum TextAlignment { LEFT, RIGHT, CENTER }
9,066
0
Create_ds/atlas/atlas-json/src/test/scala/com/netflix/atlas
Create_ds/atlas/atlas-json/src/test/scala/com/netflix/atlas/json/ObjWithLambda.java
/* * Copyright 2014-2023 Netflix, Inc. * * Licensed 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 com.netflix.atlas.json; import java.util.function.Function; /** * Simple test object to verify lambda issue with paranamer is fixed: * * https://github.com/FasterXML/jackson-module-paranamer/issues/13 * https://github.com/paul-hammant/paranamer/issues/17 * * <pre> * java.lang.ArrayIndexOutOfBoundsException: 55596 * at com.fasterxml.jackson.module.paranamer.shaded.BytecodeReadingParanamer$ClassReader.readUnsignedShort(BytecodeReadingParanamer.java:722) * at com.fasterxml.jackson.module.paranamer.shaded.BytecodeReadingParanamer$ClassReader.accept(BytecodeReadingParanamer.java:571) * at com.fasterxml.jackson.module.paranamer.shaded.BytecodeReadingParanamer$ClassReader.access$200(BytecodeReadingParanamer.java:338) * at com.fasterxml.jackson.module.paranamer.shaded.BytecodeReadingParanamer.lookupParameterNames(BytecodeReadingParanamer.java:103) * at com.fasterxml.jackson.module.paranamer.shaded.CachingParanamer.lookupParameterNames(CachingParanamer.java:79) * </pre> */ public class ObjWithLambda { private String foo; public void setFoo(String value) { final Function<String, String> check = v -> { if (v == null) throw new NullPointerException("value cannot be null"); return v; }; foo = check.apply(value); } public String getFoo() { return foo; } }
9,067
0
Create_ds/openh264/test/build/android/src/com/cisco/codec
Create_ds/openh264/test/build/android/src/com/cisco/codec/unittest/MainActivity.java
package com.cisco.codec.unittest; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.util.Log; import android.widget.TextView; import android.os.Build; import android.os.Process; public class MainActivity extends Activity { private TextView mStatusView; @Override protected void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); mStatusView = (TextView)findViewById (R.id.status_view); runUnitTest(); } @Override public void onDestroy() { super.onDestroy(); Log.i ("codec_unittest", "OnDestroy"); Process.killProcess (Process.myPid()); } public void runUnitTest() { Thread thread = new Thread() { public void run() { Log.i ("codec_unittest", "codec unittest begin"); CharSequence text = "Running..."; if (mStatusView != null) { mStatusView.setText (text); } // String path = getIntent().getStringExtra("path"); // if (path.length() <=0) // { // path = "/sdcard/codec_unittest.xml"; // } String path = "/sdcard/codec_unittest.xml"; Log.i ("codec_unittest", "codec unittest runing @" + path); DoUnittest ("/sdcard", path); Log.i ("codec_unittest", "codec unittest end"); finish(); } }; thread.start(); } static { try { System.loadLibrary ("stlport_shared"); //System.loadLibrary("openh264"); System.loadLibrary ("ut"); System.loadLibrary ("utDemo"); } catch (Exception e) { Log.v ("codec_unittest", "Load library failed"); } } public native void DoUnittest (String directory, String path); }
9,068
0
Create_ds/openh264/codec/build/android/enc/src/com/wels
Create_ds/openh264/codec/build/android/enc/src/com/wels/enc/WelsEncTest.java
package com.wels.enc; import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.os.Process; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import java.io.*; import java.util.Vector; public class WelsEncTest extends Activity { /** Called when the activity is first created. */ private OnClickListener OnClickEvent; private Button mBtnLoad, mBtnStartSW; final String mStreamPath = "/sdcard/welsenc/"; Vector<String> mCfgFiles = new Vector<String>(); @Override public void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); final TextView tv = new TextView (this); System.out.println ("Here we go ..."); Log.i (TAG, "sdcard path:" + Environment.getExternalStorageDirectory().getAbsolutePath()); setContentView (R.layout.main); mBtnLoad = (Button)findViewById (R.id.cfg); mBtnStartSW = (Button)findViewById (R.id.buttonSW); OnClickEvent = new OnClickListener() { public void onClick (View v) { switch (v.getId()) { case R.id.cfg: { String cfgFile = mStreamPath + "cfgs.txt"; try { BufferedReader bufferedReader = new BufferedReader (new FileReader (cfgFile)); String text; while ((text = bufferedReader.readLine()) != null) { mCfgFiles.add (mStreamPath + text); Log.i (TAG, mStreamPath + text); } bufferedReader.close(); } catch (IOException e) { Log.e (TAG, e.getMessage()); } } break; case R.id.buttonSW: { System.out.println ("encode sequence number = " + mCfgFiles.size()); Log.i (TAG, "after click"); try { for (int k = 0; k < mCfgFiles.size(); k++) { String cfgFile = mCfgFiles.get (k); DoEncoderTest (cfgFile); } } catch (Exception e) { Log.e (TAG, e.getMessage()); } mCfgFiles.clear(); tv.setText ("Encoder is completed!"); } break; } } }; mBtnLoad.setOnClickListener (OnClickEvent); mBtnStartSW.setOnClickListener (OnClickEvent); System.out.println ("Done!"); //run the test automatically,if you not want to autotest, just comment this line runAutoEnc(); } public void runAutoEnc() { Thread thread = new Thread() { public void run() { Log.i (TAG, "encoder performance test begin"); String inYuvfile = null, outBitfile = null, inOrgfile = null, inLayerfile = null; File encCase = new File (mStreamPath); String[] caseNum = encCase.list(); if (caseNum == null || caseNum.length == 0) { Log.i (TAG, "have not find any encoder resourse"); finish(); } for (int i = 0; i < caseNum.length; i++) { String[] yuvName = null; File yuvPath = null; File encCaseNo = new File (mStreamPath + caseNum[i]); String[] encFile = encCaseNo.list(); for (int k = 0; k < encFile.length; k++) { if (encFile[k].compareToIgnoreCase ("welsenc.cfg") == 0) inOrgfile = encCaseNo + File.separator + encFile[k]; else if (encFile[k].compareToIgnoreCase ("layer2.cfg") == 0) inLayerfile = encCaseNo + File.separator + encFile[k]; else if (encFile[k].compareToIgnoreCase ("yuv") == 0) { yuvPath = new File (encCaseNo + File.separator + encFile[k]); yuvName = yuvPath.list(); } } for (int m = 0; m < yuvName.length; m++) { inYuvfile = yuvPath + File.separator + yuvName[m]; outBitfile = inYuvfile + ".264"; Log.i (TAG, "enc yuv file:" + yuvName[m]); DoEncoderAutoTest (inOrgfile, inLayerfile, inYuvfile, outBitfile); } } Log.i (TAG, "encoder performance test finish"); finish(); } }; thread.start(); } @Override public void onStart() { Log.i (TAG, "welsencdemo onStart"); super.onStart(); } @Override public void onDestroy() { super.onDestroy(); Log.i (TAG, "OnDestroy"); Process.killProcess (Process.myPid()); } @Override public boolean onKeyDown (int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: return true; default: return super.onKeyDown (keyCode, event); } } public native void DoEncoderTest (String cfgFileName); public native void DoEncoderAutoTest (String cfgFileName, String layerFileName, String yuvFileName, String outBitsName); private static final String TAG = "welsenc"; static { try { System.loadLibrary ("openh264"); System.loadLibrary ("c++_shared"); System.loadLibrary ("welsencdemo"); Log.v (TAG, "Load libwelsencdemo.so successful"); } catch (Exception e) { Log.e (TAG, "Failed to load welsenc" + e.getMessage()); } } }
9,069
0
Create_ds/openh264/codec/build/android/dec/src/com/wels
Create_ds/openh264/codec/build/android/dec/src/com/wels/dec/WelsDecTest.java
package com.wels.dec; import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.os.Process; import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import java.io.*; import java.util.Vector; public class WelsDecTest extends Activity { /** Called when the activity is first created. */ private OnClickListener OnClickEvent; private Button mBtnLoad, mBtnStartSW; final String mStreamPath = "/sdcard/welsdec/"; Vector<String> mStreamFiles = new Vector<String>(); @Override public void onCreate (Bundle savedInstanceState) { super.onCreate (savedInstanceState); final TextView tv = new TextView (this); System.out.println ("Here we go ..."); Log.i (TAG, "sdcard path:" + Environment.getExternalStorageDirectory().getAbsolutePath()); setContentView (R.layout.main); mBtnLoad = (Button)findViewById (R.id.cfg); mBtnStartSW = (Button)findViewById (R.id.buttonSW); OnClickEvent = new OnClickListener() { public void onClick (View v) { switch (v.getId()) { case R.id.cfg: { String cfgFile = mStreamPath + "BitStreams.txt"; try { BufferedReader bufferedReader = new BufferedReader (new FileReader (cfgFile)); String text; while ((text = bufferedReader.readLine()) != null) { mStreamFiles.add (mStreamPath + text); Log.i (TAG, mStreamPath + text); } bufferedReader.close(); } catch (IOException e) { Log.e ("WELS_DEC", e.getMessage()); } } break; case R.id.buttonSW: { System.out.println ("decode sequence number = " + mStreamFiles.size()); Log.i ("WSE_DEC", "after click"); try { for (int k = 0; k < mStreamFiles.size(); k++) { String inFile = mStreamFiles.get (k); String outFile = mStreamFiles.get (k) + ".yuv"; Log.i (TAG, "input file:" + inFile + " output file:" + outFile); DoDecoderTest (inFile, outFile); } } catch (Exception e) { Log.e (TAG, e.getMessage()); } mStreamFiles.clear(); tv.setText ("Decoder is completed!"); } break; } } }; mBtnLoad.setOnClickListener (OnClickEvent); mBtnStartSW.setOnClickListener (OnClickEvent); System.out.println ("Done!"); //if you want to run the demo manually, just comment following 2 lines runAutoDec(); } public void runAutoDec() { Thread thread = new Thread() { public void run() { Log.i (TAG, "decoder performance test begin"); File bitstreams = new File (mStreamPath); String[] list = bitstreams.list(); if (list == null || list.length == 0) { Log.i (TAG, "have not find any coder resourse"); finish(); } for (int i = 0; i < list.length; i++) { String inFile = list[i]; inFile = mStreamPath + inFile; String outFile = inFile + ".yuv"; DoDecoderTest (inFile, outFile); } Log.i (TAG, "decoder performance test finish"); finish(); } }; thread.start(); } @Override public void onStart() { Log.i ("WSE_DEC", "welsdecdemo onStart"); super.onStart(); } @Override public void onDestroy() { super.onDestroy(); Log.i (TAG, "OnDestroy"); Process.killProcess (Process.myPid()); } @Override public boolean onKeyDown (int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: return true; default: return super.onKeyDown (keyCode, event); } } public native void DoDecoderTest (String infilename, String outfilename); private static final String TAG = "welsdec"; static { try { System.loadLibrary ("openh264"); System.loadLibrary ("c++_shared"); System.loadLibrary ("welsdecdemo"); Log.v (TAG, "Load libwelsdec successful"); } catch (Exception e) { Log.e (TAG, "Failed to load welsdec" + e.getMessage()); } } }
9,070
0
Create_ds/camel-k/e2e/install/cli
Create_ds/camel-k/e2e/install/cli/files/Java.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class Java extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .setHeader("m").constant("string!") .setBody().simple("Magic${header.m}") .log("${body}"); } }
9,071
0
Create_ds/camel-k/e2e/native
Create_ds/camel-k/e2e/native/files/Java2.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class Java2 extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .setHeader("m").constant("string!") .setBody().simple("Magic2${header.m}") .log("Java ${body}"); } }
9,072
0
Create_ds/camel-k/e2e/native
Create_ds/camel-k/e2e/native/files/Java.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class Java extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .setHeader("m").constant("string!") .setBody().simple("Magic${header.m}") .log("Java ${body}"); } }
9,073
0
Create_ds/camel-k/e2e/common/misc
Create_ds/camel-k/e2e/common/misc/files/TimerCustomKameletIntegration.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerCustomKameletIntegration extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:timer-custom-source?message=great%20message") .to("log:info"); } }
9,074
0
Create_ds/camel-k/e2e/common/misc
Create_ds/camel-k/e2e/common/misc/files/BadRoute.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class BadRoute extends RouteBuilder { @Override public void configure() throws Exception { from("mongodb:sample?database=sampledb&collection=mycollection&operation=findfoo") .throwException(new RuntimeException("Heyyy")) .log("bar"); } }
9,075
0
Create_ds/camel-k/e2e/common/misc
Create_ds/camel-k/e2e/common/misc/files/InvalidJava.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class InvalidJava extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .setHeader("m").constant("string!") .setBody().simple("Magic${header.m}") .log("${body}") } }
9,076
0
Create_ds/camel-k/e2e/common/misc
Create_ds/camel-k/e2e/common/misc/files/Unresolvable.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class Unresolvable extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .setHeader("m").constant("string!") .setBody().simple("Magic${header.m}") .log("${body}") .to("non-existent:hello"); } }
9,077
0
Create_ds/camel-k/e2e/common/misc
Create_ds/camel-k/e2e/common/misc/files/TimerKameletIntegration.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegration extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:my-timer-source?message=important%20message") .to("log:info"); } }
9,078
0
Create_ds/camel-k/e2e/common/misc
Create_ds/camel-k/e2e/common/misc/files/Java.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class Java extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .setHeader("m").constant("string!") .setBody().simple("Magic${header.m}") .log("${body}"); } }
9,079
0
Create_ds/camel-k/e2e/common/misc/files
Create_ds/camel-k/e2e/common/misc/files/registry/LaughingRoute.java
// camel-k: property=location=files/ /* * 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. */ import org.apache.camel.builder.RouteBuilder; public class LaughingRoute extends RouteBuilder { @Override public void configure() throws Exception { from("file:{{location}}") .convertBodyTo(String.class) .log("${body}"); } }
9,080
0
Create_ds/camel-k/e2e/common/misc/files
Create_ds/camel-k/e2e/common/misc/files/registry/FoobarDecryption.java
/* * 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. */ import camelk.DeterministicDecryption; import org.apache.camel.builder.RouteBuilder; public class FoobarDecryption extends RouteBuilder { private static final byte[] FOOBAR_ENCRYPTED = new byte[]{1, 104, -61, 45, -19, 59, 76, 38, 35, 97, 56, 49, -79, 79, 74, -79, -2, -42, -89, 76, -111, -3, -27, -102, 43, -94, 50}; @Override public void configure() throws Exception { from("timer:tick") .setBody(constant(FOOBAR_ENCRYPTED)) .bean(DeterministicDecryption.class, "decrypt(${body})") .log("${body}"); } }
9,081
0
Create_ds/camel-k/e2e/common/misc/files/registry
Create_ds/camel-k/e2e/common/misc/files/registry/classpath/Xslt.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class Xslt extends RouteBuilder { private final String XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<item>A</item>"; @Override public void configure() throws Exception { from("timer:tick?period=1s") .setBody().constant(XML) .to("xslt:xslt/cheese.xsl") .to("log:info"); } }
9,082
0
Create_ds/camel-k/e2e/common/misc/files/registry/src/main/java
Create_ds/camel-k/e2e/common/misc/files/registry/src/main/java/camelk/DeterministicDecryption.java
/* * 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 camelk; import java.io.IOException; import java.security.GeneralSecurityException; import com.google.crypto.tink.CleartextKeysetHandle; import com.google.crypto.tink.DeterministicAead; import com.google.crypto.tink.JsonKeysetReader; import com.google.crypto.tink.KeysetHandle; import com.google.crypto.tink.aead.AeadConfig; import com.google.crypto.tink.config.TinkConfig; public class DeterministicDecryption { private static final String KEYSET = "{\"primaryKeyId\":1757621741,\"key\":[{\"keyData\":{\"typeUrl\":\"type.googleapis.com/google.crypto.tink.AesSivKey\",\"value\":\"EkC4wjyYD7TPwkpxWFwkCrMmkOkpS2wdEwAchBW9INoJvmZHxBysCT0y6tfcW0RXeVWqMYqpuHfV/Np387MQcvme\",\"keyMaterialType\":\"SYMMETRIC\"},\"status\":\"ENABLED\",\"keyId\":1757621741,\"outputPrefixType\":\"TINK\"}]}"; public static String decrypt(byte[] encrypted) throws GeneralSecurityException, IOException { AeadConfig.register(); TinkConfig.register(); KeysetHandle keysetHandle = CleartextKeysetHandle.read( JsonKeysetReader.withString(KEYSET)); // Get the primitive. DeterministicAead daead = keysetHandle.getPrimitive(DeterministicAead.class); // deterministically decrypt a ciphertext. return new String(daead.decryptDeterministically(encrypted, null)); } }
9,083
0
Create_ds/camel-k/e2e/common/traits
Create_ds/camel-k/e2e/common/traits/files/ErroredRoute.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class ErroredRoute extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .setBody().simple("Hello") // We want to force a failure .setBody().simple("${mandatoryBodyAs(Boolean)}") .to("log:info"); } }
9,084
0
Create_ds/camel-k/e2e/common/traits
Create_ds/camel-k/e2e/common/traits/files/NeverReady.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class NeverReady extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick").id("never-ready") .to("controlbus:route?routeId=never-ready&action=stop&async=true") .setHeader("m").constant("string!") .setBody().simple("Magic${header.m}") .log("${body}"); } }
9,085
0
Create_ds/camel-k/e2e/common/traits
Create_ds/camel-k/e2e/common/traits/files/Master.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class Master extends RouteBuilder { @Override public void configure() throws Exception { from("master:lock:timer:tick") .setHeader("m").constant("string!") .setBody().simple("Magic${header.m}") .log("${body}"); } }
9,086
0
Create_ds/camel-k/e2e/common/traits
Create_ds/camel-k/e2e/common/traits/files/PlatformHttpServer.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class PlatformHttpServer extends RouteBuilder { @Override public void configure() throws Exception { from("platform-http:/hello?httpMethodRestrict=GET") .setBody(simple("Hello ${header.name}")); } }
9,087
0
Create_ds/camel-k/e2e/common/traits
Create_ds/camel-k/e2e/common/traits/files/ServiceBinding.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class ServiceBinding extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .setBody(simple("${properties:host}:${properties:port}")) .log("${body}"); } }
9,088
0
Create_ds/camel-k/e2e/common/traits
Create_ds/camel-k/e2e/common/traits/files/Java.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; public class Java extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .setHeader("m").constant("string!") .setBody().simple("Magic${header.m}") .log("${body}"); } }
9,089
0
Create_ds/camel-k/e2e/common/traits/files
Create_ds/camel-k/e2e/common/traits/files/jvm/Classpath.java
/* * 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. */ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.example.MyClass; public class Classpath extends RouteBuilder { @Override public void configure() throws Exception { from("timer:tick") .log(MyClass.sayHello()); } }
9,090
0
Create_ds/camel-k/e2e/common/config
Create_ds/camel-k/e2e/common/config/files/TimerKameletIntegrationConfiguration09.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegrationConfiguration09 extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:iconfig09-timer-source") .to("log:info"); } }
9,091
0
Create_ds/camel-k/e2e/common/config
Create_ds/camel-k/e2e/common/config/files/TimerKameletIntegrationConfiguration04.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegrationConfiguration04 extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:iconfig04-timer-source") .to("log:info"); } }
9,092
0
Create_ds/camel-k/e2e/common/config
Create_ds/camel-k/e2e/common/config/files/TimerKameletIntegrationConfiguration.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegrationConfiguration extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:iconfig-test-timer-source") .to("log:info"); } }
9,093
0
Create_ds/camel-k/e2e/common/config
Create_ds/camel-k/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration05.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegrationNamedConfiguration05 extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:iconfig05-timer-source/mynamedconfig") .to("log:info"); } }
9,094
0
Create_ds/camel-k/e2e/common/config
Create_ds/camel-k/e2e/common/config/files/TimerKameletIntegrationConfiguration03.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegrationConfiguration03 extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:iconfig03-timer-source") .to("log:info"); } }
9,095
0
Create_ds/camel-k/e2e/common/config
Create_ds/camel-k/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration08.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegrationNamedConfiguration08 extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:iconfig08-timer-source/mynamedconfig") .to("log:info"); } }
9,096
0
Create_ds/camel-k/e2e/common/config
Create_ds/camel-k/e2e/common/config/files/TimerKameletIntegrationConfiguration01.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegrationConfiguration01 extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:iconfig01-timer-source") .to("log:info"); } }
9,097
0
Create_ds/camel-k/e2e/common/config
Create_ds/camel-k/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration07.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegrationNamedConfiguration07 extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:iconfig07-timer-source/mynamedconfig") .to("log:info"); } }
9,098
0
Create_ds/camel-k/e2e/common/config
Create_ds/camel-k/e2e/common/config/files/TimerKameletIntegrationNamedConfiguration06.java
/* * 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. */ import java.lang.Exception; import java.lang.Override; import org.apache.camel.builder.RouteBuilder; public class TimerKameletIntegrationNamedConfiguration06 extends RouteBuilder { @Override public void configure() throws Exception { from("kamelet:iconfig06-timer-source/mynamedconfig") .to("log:info"); } }
9,099