├── .gitignore ├── CXF ├── CXF-SOAP-Authorization-OSGi │ ├── README.md │ ├── client.html │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── fusesource │ │ │ └── examples │ │ │ └── cxf │ │ │ └── jaxws │ │ │ └── security │ │ │ ├── EnableCORSInterceptor.java │ │ │ ├── HelloWorld.java │ │ │ ├── HelloWorldImpl.java │ │ │ └── client │ │ │ ├── Client.java │ │ │ ├── ClientPasswordCallback.java │ │ │ └── CustomSecurityInterceptor.java │ │ └── resources │ │ └── OSGI-INF │ │ └── blueprint │ │ └── blueprint.xml └── README.md ├── Camel ├── Camel-Fabric-Master-Component │ ├── README.md │ ├── fabric-endpoint-client │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── OSGI-INF │ │ │ └── blueprint │ │ │ └── blueprint.xml │ ├── fabric-endpoint-consumer │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── OSGI-INF │ │ │ └── blueprint │ │ │ └── blueprint.xml │ ├── fabric-endpoint-features │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── features.xml │ └── pom.xml ├── Camel-HTTP-Proxy │ ├── pom.xml │ ├── readme.md │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── test │ │ │ └── MyRouteBuilder.java │ │ └── resources │ │ ├── META-INF │ │ └── spring │ │ │ └── camel-context.xml │ │ └── log4j.properties ├── Camel-HornetQ-AMQ │ ├── README.md │ ├── features │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── resources │ │ │ │ └── features.xml │ │ └── target │ │ │ └── classes │ │ │ └── features.xml │ ├── pom.xml │ └── routing │ │ ├── pom.xml │ │ ├── src │ │ └── main │ │ │ ├── java │ │ │ └── org │ │ │ │ ├── apache │ │ │ │ └── camel │ │ │ │ │ └── demo │ │ │ │ │ └── camel_hornetq_amq │ │ │ │ │ └── TestProcessor.java │ │ │ │ └── springframework │ │ │ │ └── jms │ │ │ │ └── connection │ │ │ │ └── xa │ │ │ │ └── UserCredentialsConnectionFactoryAdapterXA.java │ │ │ └── resources │ │ │ └── META-INF │ │ │ └── spring │ │ │ └── camel-context.xml │ │ └── target │ │ ├── classes │ │ └── META-INF │ │ │ ├── MANIFEST.MF │ │ │ └── spring │ │ │ └── camel-context.xml │ │ └── maven-status │ │ └── maven-compiler-plugin │ │ └── compile │ │ └── default-compile │ │ └── createdFiles.lst ├── Camel-JMS-JDBC-XA-TX-JBossFuse6.0 │ ├── README.md │ ├── datasource │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── org │ │ │ │ └── apache │ │ │ │ └── camel │ │ │ │ └── demo │ │ │ │ └── camel_jms_jdbc_xa │ │ │ │ ├── CustomMysqlExceptionSorter.java │ │ │ │ ├── GenericResourceManager.java │ │ │ │ └── MySQLXAMCF.java │ │ │ └── resources │ │ │ └── OSGI-INF │ │ │ └── blueprint │ │ │ └── datasource.xml │ ├── features │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── features.xml │ ├── pom.xml │ └── routing │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── demo │ │ │ └── camel_jms_jdbc_xa │ │ │ ├── DemoJDBCConverter.java │ │ │ └── TestProcessor.java │ │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── TypeConverter │ │ └── OSGI-INF │ │ └── blueprint │ │ └── camel-context.xml ├── Camel-JMS-JDBC-XA-TX │ ├── README.md │ ├── datasource │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── OSGI-INF │ │ │ └── blueprint │ │ │ └── datasource.xml │ ├── features │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── features.xml │ ├── pom.xml │ └── routing │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── demo │ │ │ └── camel_jms_jdbc_xa │ │ │ ├── DemoJDBCConverter.java │ │ │ └── TestProcessor.java │ │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── TypeConverter │ │ └── OSGI-INF │ │ └── blueprint │ │ └── camel-context.xml ├── Camel-JMS-JDBC │ ├── README.md │ ├── datasource │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── OSGI-INF │ │ │ └── blueprint │ │ │ └── datasource.xml │ ├── features │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── features.xml │ ├── pom.xml │ └── routing │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── demo │ │ │ └── camel_jms_jdbc │ │ │ ├── DemoJDBCConverter.java │ │ │ └── TestProcessor.java │ │ └── resources │ │ ├── META-INF │ │ └── services │ │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── TypeConverter │ │ └── OSGI-INF │ │ └── blueprint │ │ └── camel-context.xml ├── Camel-JMS-LocalTX │ ├── README.md │ ├── optionalConfig │ │ └── activemq.xml │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── demo │ │ │ └── TestProcessor.java │ │ └── resources │ │ ├── OSGI-INF │ │ └── blueprint │ │ │ └── blueprint.xml │ │ └── log4j.properties ├── Camel-JMS-XA-TX │ ├── README.md │ ├── optionalConfig │ │ ├── activemq.xml │ │ └── blueprint-local-tx.xml │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── demo │ │ │ └── TestProcessor.java │ │ └── resources │ │ ├── OSGI-INF │ │ └── blueprint │ │ │ └── blueprint.xml │ │ └── log4j.properties ├── Camel-Jetty-Basic-Auth-Demo │ ├── pom.xml │ ├── readme.md │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── camel │ │ │ └── demo │ │ │ └── camel_jetty_basic_auth │ │ │ ├── JettyExample.java │ │ │ └── JettyExampleRoute.java │ │ └── resources │ │ └── log4j.properties ├── Camel-Jetty-Client-IP │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── apache │ │ │ │ └── camel │ │ │ │ └── test │ │ │ │ └── SimpleProcessor.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── spring │ │ │ │ └── camel-context.xml │ │ │ └── log4j.properties │ │ └── test │ │ └── java │ │ └── org │ │ └── apache │ │ └── camel │ │ └── test │ │ └── JettyHeaderTest.java ├── Camel-WMQ-AMQ-XA-TX-JBossFuse6.0 │ ├── README.md │ ├── features │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── features.xml │ ├── kill-script.sh │ ├── pom.xml │ └── routing │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ ├── apache │ │ │ └── camel │ │ │ │ └── demo │ │ │ │ └── camel_wmq_amq_xa_tx │ │ │ │ └── TestProcessor.java │ │ │ └── springframework │ │ │ └── jms │ │ │ └── connection │ │ │ └── xa │ │ │ └── UserCredentialsConnectionFactoryAdapterXA.java │ │ └── resources │ │ └── OSGI-INF │ │ └── blueprint │ │ └── camel-context.xml ├── Camel-WMQ-AMQ-XA-TX │ ├── README.md │ ├── features │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── resources │ │ │ └── features.xml │ ├── kill-script.sh │ ├── pom.xml │ └── routing │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ ├── apache │ │ │ └── camel │ │ │ │ └── demo │ │ │ │ └── camel_wmq_amq_xa_tx │ │ │ │ └── TestProcessor.java │ │ │ └── springframework │ │ │ └── jms │ │ │ └── connection │ │ │ └── xa │ │ │ └── UserCredentialsConnectionFactoryAdapterXA.java │ │ └── resources │ │ └── OSGI-INF │ │ └── blueprint │ │ └── camel-context.xml ├── Camel-Zipkin-Hawkular │ ├── README.md │ ├── client │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── sample │ │ │ │ └── camel │ │ │ │ ├── ClientApplication.java │ │ │ │ ├── ClientRoute.java │ │ │ │ └── CounterBean.java │ │ │ └── resources │ │ │ ├── META-INF │ │ │ ├── LICENSE.txt │ │ │ ├── NOTICE.txt │ │ │ └── beans.xml │ │ │ └── log4j2.properties │ ├── images │ │ ├── zipkin-web-console-1.png │ │ └── zipkin-web-console-2.png │ ├── pom.xml │ ├── service1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── sample │ │ │ │ └── camel │ │ │ │ ├── Service1Application.java │ │ │ │ └── Service1Route.java │ │ │ └── resources │ │ │ ├── META-INF │ │ │ ├── LICENSE.txt │ │ │ └── NOTICE.txt │ │ │ └── application.properties │ └── service2 │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── sample │ │ │ └── camel │ │ │ ├── Service2Application.java │ │ │ └── Service2Route.java │ │ └── resources │ │ ├── META-INF │ │ ├── LICENSE.txt │ │ └── NOTICE.txt │ │ └── log4j2.properties └── README.md ├── JBoss-Fuse ├── JBoss-Client-OSGi │ ├── EJB-Client │ │ ├── README.md │ │ ├── create-uber-jar.sh │ │ ├── pom.xml │ │ ├── run_client.sh │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── org │ │ │ │ └── apache │ │ │ │ └── servicemix │ │ │ │ └── demo │ │ │ │ └── simpleejb │ │ │ │ └── client │ │ │ │ ├── Client.java │ │ │ │ └── osgi │ │ │ │ └── OSGiActivator.java │ │ │ └── resources │ │ │ └── log4j.properties │ ├── README.md │ ├── Simple-EJB │ │ ├── README.md │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── apache │ │ │ └── servicemix │ │ │ └── demo │ │ │ └── simpleejb │ │ │ ├── SimpleGreeter.java │ │ │ └── SimpleGreeterBean.java │ └── pom.xml ├── OSGiConfigAdminManagedPropertiesExample │ ├── README.md │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── karaf │ │ │ └── demo │ │ │ ├── Ping.java │ │ │ └── impl │ │ │ ├── PingBean.java │ │ │ └── PingBean2.java │ │ └── resources │ │ └── OSGI-INF │ │ └── blueprint │ │ └── blueprint.xml ├── OSGiServiceLoadingResourcesFromExternalBundle │ ├── README.md │ ├── clientBundle │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ ├── java │ │ │ └── org │ │ │ │ └── apache │ │ │ │ └── karaf │ │ │ │ └── demo │ │ │ │ └── osgitest │ │ │ │ └── client │ │ │ │ └── Client.java │ │ │ └── resources │ │ │ └── OSGI-INF │ │ │ └── blueprint │ │ │ └── blueprint.xml │ ├── pom.xml │ └── serviceBundle │ │ ├── build.properties │ │ ├── pom.xml │ │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── apache │ │ │ └── karaf │ │ │ └── demo │ │ │ └── osgitest │ │ │ ├── OSGiTestInterface.java │ │ │ └── internal │ │ │ └── OSGiTestImpl.java │ │ └── resources │ │ └── OSGI-INF │ │ └── blueprint │ │ └── blueprint.xml ├── README.md ├── jaas-login-module-example-6.0 │ ├── pom.xml │ ├── readme.md │ └── src │ │ └── main │ │ └── resources │ │ └── OSGI-INF │ │ └── blueprint │ │ └── jaas.xml └── jaas-login-module-example-6.1 │ ├── pom.xml │ ├── readme.md │ └── src │ └── main │ └── resources │ └── OSGI-INF │ └── blueprint │ └── jaas.xml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Package Files # 4 | *.jar 5 | *.war 6 | *.ear 7 | 8 | # Eclipse project files # 9 | .project 10 | .settings 11 | .classpath 12 | 13 | # IntelliJ project files # 14 | *.iml 15 | 16 | # MacOSX specific files # 17 | .DS_Store 18 | 19 | # Maven build folder 20 | target 21 | -------------------------------------------------------------------------------- /CXF/CXF-SOAP-Authorization-OSGi/src/main/java/org/fusesource/examples/cxf/jaxws/security/EnableCORSInterceptor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.fusesource.examples.cxf.jaxws.security; 20 | 21 | import java.util.Arrays; 22 | import java.util.List; 23 | import java.util.Map; 24 | 25 | import org.apache.cxf.interceptor.Fault; 26 | import org.apache.cxf.message.Message; 27 | import org.apache.cxf.phase.AbstractPhaseInterceptor; 28 | import org.apache.cxf.phase.Phase; 29 | import org.apache.cxf.transport.http.Headers; 30 | 31 | public class EnableCORSInterceptor extends AbstractPhaseInterceptor { 32 | 33 | public EnableCORSInterceptor() { 34 | super(Phase.PRE_PROTOCOL); 35 | } 36 | 37 | @Override 38 | public void handleMessage(Message message) throws Fault { 39 | Map> headers = Headers.getSetProtocolHeaders(message); 40 | try { 41 | //Access-Control-Allow-Origin:* Access-Control-Allow-Methods:POST,GET 42 | headers.put("Access-Control-Allow-Origin", Arrays.asList("*")); 43 | headers.put("Access-Control-Allow-Methods", Arrays.asList("POST", "GET")); 44 | } catch (Exception ce) { 45 | throw new Fault(ce); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /CXF/CXF-SOAP-Authorization-OSGi/src/main/java/org/fusesource/examples/cxf/jaxws/security/HelloWorld.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | // START SNIPPET: service 20 | package org.fusesource.examples.cxf.jaxws.security; 21 | 22 | import javax.jws.WebService; 23 | 24 | /** 25 | * The HelloWorld interface defines a single method. 26 | * 27 | * We add the @WebService annotation to mark this interface as the definition for our web service. 28 | */ 29 | @WebService 30 | public interface HelloWorld { 31 | 32 | String sayHi(String name); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /CXF/CXF-SOAP-Authorization-OSGi/src/main/java/org/fusesource/examples/cxf/jaxws/security/HelloWorldImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | // START SNIPPET: service 20 | package org.fusesource.examples.cxf.jaxws.security; 21 | 22 | import javax.jws.WebService; 23 | 24 | /** 25 | * This is our web service implementation, which implements the web service interface. 26 | * We also add the @WebService annotation to it to mark this class an implementation for the endpoint interface. 27 | */ 28 | @WebService(endpointInterface = "org.fusesource.examples.cxf.jaxws.security.HelloWorld") 29 | public class HelloWorldImpl implements HelloWorld { 30 | 31 | /** 32 | * Just a simple implementation for a friendly message that says hello. 33 | */ 34 | public String sayHi(String name) { 35 | return "Hello " + name; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /CXF/CXF-SOAP-Authorization-OSGi/src/main/java/org/fusesource/examples/cxf/jaxws/security/client/Client.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.fusesource.examples.cxf.jaxws.security.client; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | import org.apache.cxf.frontend.ClientProxy; 23 | import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; 24 | import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; 25 | import org.fusesource.examples.cxf.jaxws.security.HelloWorld; 26 | 27 | /** 28 | * A Java client application that uses CXF's JaxWsProxyFactoryBean to create a web service client proxy to invoke 29 | * the remote web service. 30 | */ 31 | public class Client{ 32 | 33 | public static void main(String[] args) { 34 | try { 35 | new Client().sendRequest(); 36 | } catch (Exception e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | 41 | public void sendRequest() throws Exception { 42 | /* 43 | * Set up the JaxWsFactoryBean to access our client: 44 | * - the Java interface defining the service 45 | * - the HTTP address for the service 46 | */ 47 | JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); 48 | factory.setServiceClass(HelloWorld.class); 49 | factory.setAddress("http://localhost:8181/cxf/HelloWorldSecurity"); 50 | 51 | /* 52 | * Obtain a proxy, implementing the service interface, to access the remote interface. 53 | * It will allow you to easily perform the HTTP SOAP request from Java code. 54 | */ 55 | HelloWorld client = (HelloWorld) factory.create(); 56 | 57 | /* 58 | * Add the extra configuration and interceptors required for the authentication 59 | */ 60 | Map outProps = new HashMap(); 61 | outProps.put("action", "UsernameToken"); 62 | ClientProxy.getClient(client).getOutInterceptors().add(new CustomSecurityInterceptor()); 63 | ClientProxy.getClient(client).getOutInterceptors().add(new WSS4JOutInterceptor()); 64 | 65 | /* 66 | * Calling sayHi() on on the client object will actually perform an HTTP SOAP request instead behind the scenes 67 | * and returns the resulting response. 68 | */ 69 | String ret = client.sayHi("World"); 70 | System.out.println(ret); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /CXF/CXF-SOAP-Authorization-OSGi/src/main/java/org/fusesource/examples/cxf/jaxws/security/client/ClientPasswordCallback.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.fusesource.examples.cxf.jaxws.security.client; 20 | 21 | import java.io.IOException; 22 | import javax.security.auth.callback.Callback; 23 | import javax.security.auth.callback.CallbackHandler; 24 | import javax.security.auth.callback.UnsupportedCallbackException; 25 | import org.apache.ws.security.WSPasswordCallback; 26 | 27 | /** 28 | * This is a JAAS CallbackHandler implementation that will provide the password for our custom security interceptor. 29 | */ 30 | public class ClientPasswordCallback implements CallbackHandler { 31 | 32 | /* 33 | * Handle the authentication callback by checking the identifier and just hard-coded returning the correct password. 34 | */ 35 | public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { 36 | WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; 37 | 38 | /* 39 | * User is 'admin', password is 'admin' 40 | */ 41 | if (pc.getIdentifier().equals("admin")) { 42 | pc.setPassword("admin"); 43 | } 44 | } 45 | 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /CXF/CXF-SOAP-Authorization-OSGi/src/main/java/org/fusesource/examples/cxf/jaxws/security/client/CustomSecurityInterceptor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.fusesource.examples.cxf.jaxws.security.client; 20 | 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | import org.apache.cxf.interceptor.Fault; 25 | import org.apache.cxf.interceptor.Interceptor; 26 | import org.apache.cxf.message.Message; 27 | import org.apache.cxf.phase.AbstractPhaseInterceptor; 28 | import org.apache.cxf.phase.Phase; 29 | import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; 30 | 31 | /** 32 | * CXF Interceptors are a very powerful and flexible mechanism to add custom logic to the default CXF processing, 33 | * both when using CXF on the client side and on the server side. 34 | * 35 | * With this custom security interceptor, we will configure the default WSS4J interceptor in the client to provide the required 36 | * credentials to perform our web service invocation. 37 | */ 38 | public class CustomSecurityInterceptor extends AbstractPhaseInterceptor { 39 | 40 | /** 41 | * Configuring the interceptor to be used in the 'setup' phase. 42 | */ 43 | public CustomSecurityInterceptor() { 44 | super(Phase.SETUP); 45 | } 46 | 47 | /** 48 | * This is the actual implementation for our interceptor - we define the necessary properties for doing the authentication 49 | * and then iterate over the rest of the interceptor chain to find the WSS4J interceptor and configure it properly. 50 | */ 51 | public void handleMessage(Message message) throws Fault { 52 | /* 53 | * Define the configuration properties 54 | */ 55 | Map outProps = new HashMap(); 56 | outProps.put("action", "UsernameToken"); 57 | outProps.put("passwordType", "PasswordText"); 58 | 59 | /* 60 | * The username ('admin') is provided as a literal, the corresponding password will be determined by the client 61 | * password callback object. 62 | */ 63 | outProps.put("user", "admin"); 64 | outProps.put("passwordCallbackClass", ClientPasswordCallback.class.getName()); 65 | 66 | /* 67 | * Find the WSS4J interceptor in the interceptor chain and set the configuration properties 68 | */ 69 | for (Interceptor interceptor : message.getInterceptorChain()) { 70 | //set properties for WSS4JOutInterceptor 71 | if (interceptor.getClass().getName().equals("org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor")) { 72 | ((WSS4JOutInterceptor) interceptor).setProperties(outProps); 73 | } 74 | } 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /CXF/README.md: -------------------------------------------------------------------------------- 1 | ## This directory contains CXF related demos 2 | 3 | -------------------------------------------------------------------------------- /Camel/Camel-Fabric-Master-Component/fabric-endpoint-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | com.fusesource.examples 23 | fabric-endpoint-example 24 | 1.0-SNAPSHOT 25 | 26 | 4.0.0 27 | 28 | fabric-endpoint-client 29 | Fabric Endpoint Example: Client 30 | bundle 31 | 32 | 33 | 34 | org.apache.camel 35 | camel-core 36 | 37 | 38 | 39 | 40 | install 41 | 42 | 43 | 44 | org.apache.felix 45 | maven-bundle-plugin 46 | true 47 | 48 | 49 | * 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /Camel/Camel-Fabric-Master-Component/fabric-endpoint-client/src/main/resources/OSGI-INF/blueprint/blueprint.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | ${properties:name} said: Hello Consumer! 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /Camel/Camel-Fabric-Master-Component/fabric-endpoint-consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | 22 | com.fusesource.examples 23 | fabric-endpoint-example 24 | 1.0-SNAPSHOT 25 | 26 | 4.0.0 27 | 28 | fabric-endpoint-consumer 29 | Fabric Endpoint Example: Consumer 30 | bundle 31 | 32 | 33 | 34 | org.apache.camel 35 | camel-core 36 | 37 | 47 | 48 | 49 | 50 | install 51 | 52 | 53 | 54 | org.apache.felix 55 | maven-bundle-plugin 56 | true 57 | 58 | 59 | * 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Camel/Camel-Fabric-Master-Component/fabric-endpoint-consumer/src/main/resources/OSGI-INF/blueprint/blueprint.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ${properties:name} said: Goodmorning Client. 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Camel/Camel-Fabric-Master-Component/fabric-endpoint-features/src/main/resources/features.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | camel-jetty 22 | fabric-camel 23 | mvn:com.fusesource.examples/fabric-endpoint-client/1.0-SNAPSHOT 24 | 25 | 26 | 27 | camel-jetty 28 | fabric-camel 29 | mvn:com.fusesource.examples/fabric-endpoint-consumer/1.0-SNAPSHOT 30 | 31 | -------------------------------------------------------------------------------- /Camel/Camel-HTTP-Proxy/readme.md: -------------------------------------------------------------------------------- 1 | # Camel HTTP Proxy demo 2 | 3 | A quick demo that shows how to do HTTP proxying in Camel. 4 | For additional documentation see 5 | https://access.redhat.com/site/documentation/en-US/JBoss_Fuse/6.0/html/Web_Services_and_Routing_with_Camel_CXF/files/Proxying-HTTP.html 6 | 7 | This demo uses the following route definition 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | and proxies any HTTP requests coming to the url http://localhost:9000/weather to 18 | the external HTTP address http://weather.yahoo.com/united-states. 19 | 20 | 21 | The most interesting files are 22 | src/main/resources/META-INF/spring/camel-context.xml 23 | src/main/java/org/apache/camel/test/MyRouteBuilder.java 24 | 25 | 26 | 27 | ## Compiling 28 | 29 | - mvn install 30 | 31 | 32 | 33 | ## Running 34 | 35 | - mvn camel:run 36 | - open a browser and type any of these urls 37 | http://localhost:9000/weather/california 38 | http://localhost:9000/weather/california/acton-2351805 39 | http://localhost:9000/weather/massachusetts 40 | http://localhost:9000/weather/massachusetts/boston-2367105 -------------------------------------------------------------------------------- /Camel/Camel-HTTP-Proxy/src/main/java/org/apache/camel/test/MyRouteBuilder.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.apache.camel.test; 5 | 6 | import org.apache.camel.builder.RouteBuilder; 7 | 8 | /** 9 | * Sets up the same HTTP Proxy route that is defined in camel-context.xml 10 | * but using the Java DSL. 11 | * @author tmielke 12 | * 13 | */ 14 | public class MyRouteBuilder extends RouteBuilder { 15 | 16 | /* (non-Javadoc) 17 | * @see org.apache.camel.builder.RouteBuilder#configure() 18 | */ 19 | @Override 20 | public void configure() throws Exception { 21 | 22 | from("jetty://http://localhost:9100/weather?matchOnUriPrefix=true"). 23 | to("http://weather.yahoo.com/united-states?bridgeEndpoint=true&throwExceptionOnFailure=false&traceEnabled"). 24 | to("log:MyLogger?level=INFO&showAll=true"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Camel/Camel-HTTP-Proxy/src/main/resources/META-INF/spring/camel-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | org.apache.camel.test 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Camel/Camel-HTTP-Proxy/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ## ------------------------------------------------------------------------ 2 | ## Licensed to the Apache Software Foundation (ASF) under one or more 3 | ## contributor license agreements. See the NOTICE file distributed with 4 | ## this work for additional information regarding copyright ownership. 5 | ## The ASF licenses this file to You under the Apache License, Version 2.0 6 | ## (the "License"); you may not use this file except in compliance with 7 | ## the License. You may obtain a copy of the License at 8 | ## 9 | ## http://www.apache.org/licenses/LICENSE-2.0 10 | ## 11 | ## Unless required by applicable law or agreed to in writing, software 12 | ## distributed under the License is distributed on an "AS IS" BASIS, 13 | ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ## See the License for the specific language governing permissions and 15 | ## limitations under the License. 16 | ## ------------------------------------------------------------------------ 17 | 18 | # 19 | # The logging properties used 20 | # 21 | log4j.rootLogger=INFO, out 22 | 23 | # uncomment the following line to turn on Camel debugging 24 | #log4j.logger.org.apache.camel=DEBUG 25 | 26 | # uncomment the following line to turn on ActiveMQ debugging 27 | #log4j.logger.org.apache.activemq=DEBUG 28 | 29 | log4j.logger.org.springframework=INFO 30 | log4j.logger.org.apache.camel=DEBUG 31 | 32 | # CONSOLE appender not used by default 33 | log4j.appender.out=org.apache.log4j.ConsoleAppender 34 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 35 | log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n 36 | #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 37 | 38 | log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer -------------------------------------------------------------------------------- /Camel/Camel-HornetQ-AMQ/features/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.apache.camel.demo 25 | camel-hornetq-amq 26 | 1.0.0 27 | 28 | 29 | org.apache.camel.demo.camel-hornetq-amq 30 | features 31 | pom 32 | Camel :: Demo :: Camel HornetQ to ActiveMQ :: Features 33 | 34 | 35 | 36 | 37 | src/main/resources 38 | true 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-resources-plugin 45 | 46 | 47 | filter 48 | generate-resources 49 | 50 | resources 51 | 52 | 53 | 54 | 55 | 56 | org.codehaus.mojo 57 | build-helper-maven-plugin 58 | 1.7 59 | 60 | 61 | attach-artifact 62 | package 63 | 64 | attach-artifact 65 | 66 | 67 | 68 | 69 | target/classes/features.xml 70 | xml 71 | features 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Camel/Camel-HornetQ-AMQ/features/src/main/resources/features.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.5_spec/2.0.0 28 | 29 | 30 | wrap:file:///Volumes/Transcend/JBoss/EAP/jboss-eap-6.2/bin/client/jboss-client.jar 31 | 32 | 44 | 45 | activemq-client 46 | 47 | 48 | mvn:${project.groupId}/routing/${project.version} 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Camel/Camel-HornetQ-AMQ/features/target/classes/features.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.5_spec/2.0.0 28 | 29 | 30 | wrap:file:///Volumes/Transcend/JBoss/EAP/jboss-eap-6.2/bin/client/jboss-client.jar 31 | 32 | 44 | 45 | activemq-client 46 | 47 | 48 | mvn:org.apache.camel.demo.camel-hornetq-amq/routing/1.0.0 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /Camel/Camel-HornetQ-AMQ/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | org.apache.camel.demo 7 | camel-hornetq-amq 8 | 1.0.0 9 | Camel :: Demo :: Camel HornetQ to ActiveMQ 10 | pom 11 | 12 | 13 | 2.10.0.fuse-71-047 14 | 5.8.0.redhat-60024 15 | 16 | 17 | 18 | features 19 | routing 20 | 21 | 22 | 23 | 24 | fusesource.release 25 | FuseSource Release Repo 26 | http://repo.fusesource.com/nexus/content/groups/public/ 27 | 28 | true 29 | 30 | 31 | false 32 | 33 | 34 | 35 | 36 | 37 | fusesource.release 38 | FuseSource Release Repo 39 | http://repo.fusesource.com/nexus/content/groups/public/ 40 | 41 | true 42 | 43 | 44 | false 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.felix 53 | maven-bundle-plugin 54 | 2.3.7 55 | true 56 | 57 | 58 | org.apache.maven.plugins 59 | maven-compiler-plugin 60 | 3.0 61 | true 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Camel/Camel-HornetQ-AMQ/routing/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.apache.camel.demo 8 | camel-hornetq-amq 9 | 1.0.0 10 | 11 | 12 | org.apache.camel.demo.camel-hornetq-amq 13 | routing 14 | 1.0.0 15 | Camel :: Demo :: Camel HornetQ to ActiveMQ :: Routing 16 | bundle 17 | 18 | 19 | 20 | 21 | javax.jms;version="[1.1,2)", 22 | org.apache.camel;version="[2.10,3)", 23 | org.jboss.naming.remote.client, 24 | org.slf4j;version="[1.6,2)", 25 | org.springframework.beans.factory, 26 | org.springframework.core, 27 | org.springframework.util, 28 | org.hornetq.jms.client, 29 | org.hornetq.api.core.client, 30 | org.hornetq.core.client.impl, 31 | org.hornetq.api.core, 32 | * 33 | 34 | 35 | 36 | 37 | org.apache.camel.demo.camel_hornetq_amq 38 | 39 | 40 | 41 | 42 | 51 | 52 | org.apache.camel 53 | camel-jms 54 | ${camel.version} 55 | 56 | 57 | org.apache.camel 58 | camel-spring 59 | ${camel.version} 60 | 61 | 62 | org.apache.activemq 63 | activemq-client 64 | ${activemq.version} 65 | 66 | 67 | org.apache.activemq 68 | activemq-pool 69 | ${activemq.version} 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.apache.felix 77 | maven-bundle-plugin 78 | true 79 | 80 | 81 | ${servicemix.osgi.export} 82 | ${servicemix.osgi.import} 83 | ${servicemix.osgi.bundles} 84 | ${servicemix.osgi.private} 85 | true 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Camel/Camel-HornetQ-AMQ/routing/src/main/java/org/apache/camel/demo/camel_hornetq_amq/TestProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.apache.camel.demo.camel_hornetq_amq; 17 | 18 | import java.util.concurrent.atomic.AtomicInteger; 19 | 20 | import org.apache.camel.Exchange; 21 | import org.apache.camel.Processor; 22 | 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | 27 | /** 28 | * Dummy Camel Processor that simulates msg processing. 29 | * Increments a static counter for each msgs received. 30 | * 31 | * Can also be used to raise an exception for every X msg 32 | * to illustrate how an exception causes the transaction to be rolled 33 | * back. 34 | * 35 | */ 36 | public class TestProcessor implements Processor { 37 | private static AtomicInteger counter = new AtomicInteger(0); 38 | 39 | // whether to simulate a processing error by raising an exception 40 | private boolean simulateProcessingError = false; 41 | 42 | // if simulateProcessingError=true, then throw exception 43 | // every errorAfterMsgs messages. 44 | private int errorAfterMsgs = 5; 45 | 46 | private Logger log = LoggerFactory.getLogger(TestProcessor.class); 47 | 48 | 49 | public void process(Exchange exchange) throws Exception { 50 | 51 | if (log.isTraceEnabled()) 52 | log.trace("starting to process messages."); 53 | 54 | // increment counter 55 | counter.incrementAndGet(); 56 | 57 | // should we simulate a processing error? 58 | if (simulateProcessingError) { 59 | if (counter.get() % errorAfterMsgs == 0) { 60 | throw new RuntimeException("Thrown from Camel Processor to simulate an exception in Camel route"); 61 | } 62 | } 63 | 64 | if (log.isTraceEnabled()) 65 | log.trace("Finished msg processing. Counter is at " + counter.get()); 66 | } 67 | 68 | 69 | /* Getter and Setter methods */ 70 | public boolean isSimulateProcessingError() { 71 | return simulateProcessingError; 72 | } 73 | 74 | 75 | public void setSimulateProcessingError(boolean simulateProcessingError) { 76 | this.simulateProcessingError = simulateProcessingError; 77 | } 78 | 79 | 80 | public int getErrorAfterMsgs() { 81 | return errorAfterMsgs; 82 | } 83 | 84 | 85 | public void setErrorAfterMsgs(int errorAfterMsgs) { 86 | this.errorAfterMsgs = errorAfterMsgs; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Camel/Camel-HornetQ-AMQ/routing/target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bnd-LastModified: 1418057188573 3 | Build-Jdk: 1.7.0_45 4 | Built-By: tmielke 5 | Bundle-ManifestVersion: 2 6 | Bundle-Name: Camel :: Demo :: Camel HornetQ to ActiveMQ :: Routing 7 | Bundle-SymbolicName: org.apache.camel.demo.camel-hornetq-amq.routing 8 | Bundle-Version: 1.0.0 9 | Created-By: Apache Maven Bundle Plugin 10 | DynamicImport-Package: true 11 | Import-Package: javax.jms;version="[1.1,2)",org.apache.activemq,org.apac 12 | he.activemq.pool,org.apache.camel;version="[2.10,3)",org.apache.camel.c 13 | omponent.jms;version="[2.10,3)",org.hornetq.api.core,org.hornetq.api.co 14 | re.client,org.hornetq.core.client.impl,org.hornetq.jms.client,org.jboss 15 | .naming.remote.client,org.slf4j;version="[1.6,2)",org.springframework.b 16 | eans.factory;version="[3.0,4)",org.springframework.core;version="[3.0,4 17 | )",org.springframework.jms.connection;version="[3.0,4)",org.springframe 18 | work.util;version="[3.0,4)" 19 | Tool: Bnd-1.50.0 20 | -------------------------------------------------------------------------------- /Camel/Camel-HornetQ-AMQ/routing/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst: -------------------------------------------------------------------------------- 1 | org/springframework/jms/connection/xa/UserCredentialsConnectionFactoryAdapterXA$JmsUserCredentials.class 2 | org/apache/camel/demo/camel_hornetq_amq/TestProcessor.class 3 | org/springframework/jms/connection/xa/UserCredentialsConnectionFactoryAdapterXA.class 4 | org/springframework/jms/connection/xa/UserCredentialsConnectionFactoryAdapterXA$1.class 5 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/datasource/README.md: -------------------------------------------------------------------------------- 1 | # Datasource bundle 2 | This bundle defines the JDBC `DataSource`s that will be used for accessing the 3 | relational database. 4 | 5 | 6 | ## Blueprint 7 | We are using Blueprint to define the data source bean and publish it into the OSGi Service Registry. Have a look at 8 | `src/main/resources/OSGI-INF/blueprint/datasource.xml` for more details about how this done. 9 | 10 | Due to bug http://fusesource.com/issues/browse/ENTESB-633 it is not possible to 11 | have the configured JDBC DataSource getting auto-enlisted into Aries. 12 | Instead a workaround solution is presented in src/main/resources/OSGI-INF/blueprint/datasource.xml 13 | 14 | 15 | ## Checking the OSGi Service Registry 16 | After the bundle is started, we can use the Fuse ESB Enterprise console to look at the registered objects in the registry. 17 | 18 | First, find the bundle id for the bundle called " ESB :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource" by using the `osgi:list` command. 19 | You can use `grep` to filter the list of bundles and quickly find the right one. 20 | 21 | FuseESB:karaf@root> osgi:list | grep Transactions 22 | [ 268] [Active ] [Created ] [ ] [ 60] ESB :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource (1.0.0) 23 | [ 269] [Active ] [ ] [Started] [ 60] ESB :: Demo :: Camel-JMS-JDBC-XA-TX :: Routing (1.0.0) 24 | 25 | In this example, the bundle id is 268. Using the `osgi:ls` command, we can see that this bundle is publishing 3 services: 26 | 27 | * first, there's the `javax.sql.XADataSource` that we created in our Blueprint XML file 28 | * secondly, Aries JTA has added a corresponding `javax.sql.DataSource` and added the `aries.xa.aware = true` property to it to indicate an XA-aware data source 29 | * finally, the Blueprint extender mechanism also published the Blueprint container (containg our data source bean definitions) it created 30 | 31 | This is what the `osgi:ls` output looks like 32 | 33 | FuseESB:karaf@root> osgi:ls 268 34 | 35 | Camel :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource (268) provides: 36 | ------------------------------------------------------------- 37 | datasource.name = MySQL 38 | objectClass = javax.sql.XADataSource 39 | osgi.jndi.service.name = jdbc/transactions 40 | osgi.service.blueprint.compname = mysql-cf 41 | service.id = 414 42 | ---- 43 | aries.xa.aware = true 44 | datasource.name = MySQL 45 | objectClass = javax.sql.DataSource 46 | osgi.jndi.service.name = jdbc/transactions 47 | osgi.service.blueprint.compname = mysql-cf 48 | service.id = 415 49 | service.ranking = 1000 50 | ---- 51 | objectClass = org.osgi.service.blueprint.container.BlueprintContainer 52 | osgi.blueprint.container.symbolicname = org.apache.servicemix.demo.camel-jms-jdbc-xa-tx.datasource 53 | osgi.blueprint.container.version = 1.0.0 54 | service.id = 416 55 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/datasource/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.apache.camel.demo 25 | camel-jms-jdbc-xa 26 | 2.0.0 27 | 28 | 29 | org.apache.camel.demo.camel-jms-jdbc-xa 30 | datasource 31 | bundle 32 | Camel :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource 33 | 2.0.0 34 | 35 | 36 | 37 | org.apache.geronimo.components 38 | geronimo-connector 39 | 2.2.2 40 | 41 | 42 | 43 | 44 | org.tranql 45 | tranql-connector 46 | 1.8 47 | 48 | 49 | org.tranql 50 | tranql-connector-mysql-common 51 | 1.6 52 | 53 | 54 | mysql 55 | mysql-connector-java 56 | 5.1.17 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.apache.felix 66 | maven-bundle-plugin 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/datasource/src/main/java/org/apache/camel/demo/camel_jms_jdbc_xa/CustomMysqlExceptionSorter.java: -------------------------------------------------------------------------------- 1 | package org.apache.camel.demo.camel_jms_jdbc_xa; 2 | 3 | import java.sql.SQLException; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | import org.tranql.connector.mysql.MysqlExceptionSorter; 9 | 10 | /** 11 | * Extends org.tranql.connector.mysql.MySqlExceptionSorter 12 | * so that some SQLExceptions can be considered fatal. 13 | * This allows transaction roll back on any errors. 14 | * Further fine tuning of the different error codes is recommended. 15 | */ 16 | public class CustomMysqlExceptionSorter extends MysqlExceptionSorter { 17 | 18 | Logger log = LoggerFactory.getLogger(CustomMysqlExceptionSorter.class.getName()); 19 | 20 | 21 | /** 22 | * Return true if the exception is an SQLException. 23 | * Further fine tuning might be needed. 24 | * 25 | * @param e the exception to check 26 | * @return true if the connection should be discarded 27 | */ 28 | @Override 29 | public boolean isExceptionFatal(Exception e) { 30 | if (e instanceof SQLException) { 31 | // TODO: check error codes and decide whether the ex is fatal. 32 | log.debug("Received exception {}", ((SQLException)e).getMessage()); 33 | return true; 34 | } 35 | return false; 36 | } 37 | 38 | 39 | /** 40 | * Whether to roll back on fatal exceptions or not. 41 | * @return trues - always roll back 42 | */ 43 | @Override 44 | public boolean rollbackOnFatalException() { 45 | return true; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/datasource/src/main/java/org/apache/camel/demo/camel_jms_jdbc_xa/GenericResourceManager.java: -------------------------------------------------------------------------------- 1 | package org.apache.camel.demo.camel_jms_jdbc_xa; 2 | 3 | import javax.resource.spi.ManagedConnectionFactory; 4 | import org.apache.geronimo.connector.outbound.ConnectionManagerContainer; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * Generic resource manager wrapper. 10 | * Only needed for working around 11 | * http://fusesource.com/issues/browse/ENTESB-633. 12 | * Simply delegates the call to doRecovery() to the configured 13 | * Geronimo ConnectionManagerContainer. 14 | */ 15 | public class GenericResourceManager { 16 | 17 | Logger logger = LoggerFactory.getLogger(GenericResourceManager.class.getName()); 18 | 19 | private ConnectionManagerContainer connectionManagerContainer; 20 | private ManagedConnectionFactory managedConnectionFactory; 21 | 22 | public synchronized void setConnectionManagerContainer( 23 | ConnectionManagerContainer connectionManagerContainer) { 24 | this.connectionManagerContainer = connectionManagerContainer; 25 | } 26 | 27 | public synchronized void setManagedConnectionFactory( 28 | ManagedConnectionFactory managedConnectionFactory) { 29 | this.managedConnectionFactory = managedConnectionFactory; 30 | } 31 | 32 | 33 | public void doRecovery() { 34 | logger.info("Recovering XA resource " + managedConnectionFactory); 35 | connectionManagerContainer.doRecovery(managedConnectionFactory); 36 | } 37 | } -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/features/README.md: -------------------------------------------------------------------------------- 1 | # Features 2 | This project creates a features definition that can be used to easily install the example. 3 | 4 | ## How it works? 5 | Using Maven's resource filtering mechanism, we replace the `${xyz.version}` tokens in the `src/main/resources/features.xml` file. 6 | Afterwards, the resulting file is published as a Maven artifact itself so you can use it from within the Fuse ESB console with 7 | 8 | FuseESB:karaf@root> features:addurl mvn:org.apache.servicemix.demo.camel-jms-jdbc-xa-tx/features/1.0.0/xml/features 9 | 10 | Inside the features file, you'll find a definition for feature called `camel-jms-jdbc-xa-demo`. -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/features/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.apache.camel.demo 25 | camel-jms-jdbc-xa 26 | 2.0.0 27 | 28 | 29 | org.apache.camel.demo.camel-jms-jdbc-xa 30 | features 31 | pom 32 | Camel :: Demo :: Camel-JMS-JDBC-XA-TX :: Features 33 | 34 | 35 | 36 | 37 | src/main/resources 38 | true 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-resources-plugin 45 | 46 | 47 | filter 48 | generate-resources 49 | 50 | resources 51 | 52 | 53 | 54 | 55 | 56 | org.codehaus.mojo 57 | build-helper-maven-plugin 58 | 1.7 59 | 60 | 61 | attach-artifact 62 | package 63 | 64 | attach-artifact 65 | 66 | 67 | 68 | 69 | target/classes/features.xml 70 | xml 71 | features 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/features/src/main/resources/features.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | mvn:org.apache.geronimo.components/geronimo-connector/2.2.2 8 | mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.5_spec/2.0.0 9 | 10 | 11 | 15 | 16 | wrap:mvn:mysql/mysql-connector-java/5.1.17 17 | wrap:mvn:org.tranql/tranql-connector/1.8 18 | wrap:mvn:org.tranql/tranql-connector-mysql-common/1.6 19 | 20 | 21 | camel-sql 22 | mvn:org.apache.camel/camel-jms/${camel.version} 23 | mvn:org.apache.camel/camel-jdbc/${camel.version} 24 | 25 | 26 | mvn:${project.groupId}/routing/${project.version} 27 | mvn:${project.groupId}/datasource/${project.version} 28 | 29 | 30 | 34 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | org.apache.camel.demo 6 | camel-jms-jdbc-xa 7 | 2.0.0 8 | Camel :: Demo :: Camel-JMS-JDBC-XA-TX 9 | pom 10 | 11 | 12 | 2.10.0.fuse-71-047 13 | 5.8.0.redhat-60015 14 | 7.0.37 15 | 6.0.36 16 | 5.1.17 17 | 18 | 19 | 20 | features 21 | datasource 22 | routing 23 | 24 | 25 | 26 | 27 | 28 | 29 | org.apache.felix 30 | maven-bundle-plugin 31 | 2.3.7 32 | true 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-compiler-plugin 37 | 3.0 38 | true 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/routing/README.md: -------------------------------------------------------------------------------- 1 | # Routing 2 | 3 | This project contains the actual Camel route definition and JMS endpoint configuration using 4 | OSGi blueprint configuration. 5 | 6 | That configuration is in 7 | src/main/resources/OSGI-INF/blueprint/camel-context.xml 8 | 9 | It defines two Camel route, one using the camel-jdbc component, the other 10 | using the camel-sql component. 11 | 12 | In order to fill in data into the SQL statement created by the camel-sql 13 | component, it requires an object array if more than one value is to be 14 | replaced in the SQL statement. 15 | 16 | In the routing step 17 | 18 | 19 | 4 values are inserted into the SQL statement, so an object array of 4 strings 20 | is required. The source of this Camel route however is a JMS endpoint which 21 | receives a single JMS message at a time. 22 | The idea here is that we assume a JMS TextMessage with a comma separated list of 23 | values and use a custom Camel converter to convert this TextMessage into an 24 | object array. 25 | This Camel converter class is defined in 26 | src/main/java/org/apache/servicemix/demo/camel_jms_jdbc_xa_demo/DemoJDBCConverter.java 27 | 28 | 29 | Perhaps also take a minute to study the configuration of the JMS component. 30 | Note the ConnectionFactory used is of type org.apache.activemq.pool.JcaPooledConnectionFactory. 31 | When using XA transactions and enlisting into the Aries transaction manager, 32 | then this ConnectionFactory is needed. In addition it needs to be configured 33 | for a unique name property as that name identifies the XA resource when Aries 34 | writes its transaction log file. 35 | 36 | The same unique name needs to be configured for ActiveMQResourceManager bean 37 | definition. The resource manager is called on startup and asks the broker for 38 | any outstanding transactions that are then to be committed or rolled back. 39 | 40 | Further please notice the cacheLevelName is set to CACHE_CONNECTION which is the 41 | recommendation for XA transactions. 42 | 43 | And finally notice the brokerURL property of the ActiveMQXAConnectionFactory uses 44 | the url failover:(tcp://localhost:61616)?jms.prefetchPolicy.all=1. Using a 45 | prefetch of just one message makes sense since we don't cache JMS sessions and 46 | JMS consumers at Spring level. So a new JMS consumer gets created for every new 47 | message that is to be consumed. If the default prefetch of 1000 was used we 48 | would potentially prefetch up to 1000 messages to each consumer although 49 | only one message is processed before the consumer is destroyed again 50 | (which rejects all remaining 999 messages). 51 | 52 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/routing/src/main/java/org/apache/camel/demo/camel_jms_jdbc_xa/TestProcessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.camel.demo.camel_jms_jdbc_xa; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | /** 12 | * Dummy Camel Processor that simulates msg processing. 13 | * Increments a static counter for each msgs received. 14 | * 15 | * Can also be used to raise an exception for every X msg 16 | * to illustrate how an exception causes the XA transaction to be rolled back. 17 | */ 18 | public class TestProcessor implements Processor { 19 | private static AtomicInteger counter = new AtomicInteger(0); 20 | 21 | // whether to simulate a processing error by raising an exception 22 | private boolean simulateProcessingError = false; 23 | 24 | // if simulateProcessingError=true, then throw exception 25 | // every errorAfterMsgs messages. 26 | private int errorAfterMsgs = 5; 27 | 28 | private Logger log = LoggerFactory.getLogger(TestProcessor.class); 29 | 30 | 31 | public void process(Exchange exchange) throws Exception { 32 | 33 | if (log.isTraceEnabled()) 34 | log.trace("starting to process messages."); 35 | 36 | // increment counter 37 | counter.incrementAndGet(); 38 | 39 | // should we simulate a processing error? 40 | if (simulateProcessingError) { 41 | if (counter.get() % errorAfterMsgs == 0) { 42 | throw new RuntimeException("Thrown from Camel Processor to simulate an exception in Camel route"); 43 | } 44 | } 45 | if (log.isTraceEnabled()) 46 | log.trace("Finished msg processing. Counter is at " + counter.get()); 47 | } 48 | 49 | 50 | /* Getter and Setter methods */ 51 | public boolean isSimulateProcessingError() { 52 | return simulateProcessingError; 53 | } 54 | 55 | 56 | public void setSimulateProcessingError(boolean simulateProcessingError) { 57 | this.simulateProcessingError = simulateProcessingError; 58 | } 59 | 60 | public int getErrorAfterMsgs() { 61 | return errorAfterMsgs; 62 | } 63 | 64 | 65 | public void setErrorAfterMsgs(int errorAfterMsgs) { 66 | this.errorAfterMsgs = errorAfterMsgs; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX-JBossFuse6.0/routing/src/main/resources/META-INF/services/org/apache/camel/TypeConverter: -------------------------------------------------------------------------------- 1 | org.apache.camel.demo.camel_jms_jdbc_xa 2 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/datasource/README.md: -------------------------------------------------------------------------------- 1 | # Datasource bundle 2 | This bundle defines the JDBC `DataSource`s that will be used for accessing the 3 | relational database. 4 | 5 | 6 | ## Blueprint 7 | We are using Blueprint to define the data source bean and publish it into the OSGi Service Registry. Have a look at 8 | `src/main/resources/OSGI-INF/blueprint/datasource.xml` for more details about how this done. 9 | 10 | Due to bug http://fusesource.com/issues/browse/ENTESB-633 it is not possible to 11 | have the configured JDBC DataSource getting auto-enlisted into Aries. 12 | Instead a workaround solution is presented in src/main/resources/OSGI-INF/blueprint/datasource.xml 13 | 14 | 15 | ## Checking the OSGi Service Registry 16 | After the bundle is started, we can use the Fuse ESB Enterprise console to look at the registered objects in the registry. 17 | 18 | First, find the bundle id for the bundle called " ESB :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource" by using the `osgi:list` command. 19 | You can use `grep` to filter the list of bundles and quickly find the right one. 20 | 21 | FuseESB:karaf@root> osgi:list | grep Transactions 22 | [ 268] [Active ] [Created ] [ ] [ 60] ESB :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource (1.0.0) 23 | [ 269] [Active ] [ ] [Started] [ 60] ESB :: Demo :: Camel-JMS-JDBC-XA-TX :: Routing (1.0.0) 24 | 25 | In this example, the bundle id is 268. Using the `osgi:ls` command, we can see that this bundle is publishing 3 services: 26 | 27 | * first, there's the `javax.sql.XADataSource` that we created in our Blueprint XML file 28 | * secondly, Aries JTA has added a corresponding `javax.sql.DataSource` and added the `aries.xa.aware = true` property to it to indicate an XA-aware data source 29 | * finally, the Blueprint extender mechanism also published the Blueprint container (containg our data source bean definitions) it created 30 | 31 | This is what the `osgi:ls` output looks like 32 | 33 | FuseESB:karaf@root> osgi:ls 268 34 | 35 | Camel :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource (268) provides: 36 | ------------------------------------------------------------- 37 | datasource.name = MySQL 38 | objectClass = javax.sql.XADataSource 39 | osgi.jndi.service.name = jdbc/transactions 40 | osgi.service.blueprint.compname = mysql-cf 41 | service.id = 414 42 | ---- 43 | aries.xa.aware = true 44 | datasource.name = MySQL 45 | objectClass = javax.sql.DataSource 46 | osgi.jndi.service.name = jdbc/transactions 47 | osgi.service.blueprint.compname = mysql-cf 48 | service.id = 415 49 | service.ranking = 1000 50 | ---- 51 | objectClass = org.osgi.service.blueprint.container.BlueprintContainer 52 | osgi.blueprint.container.symbolicname = org.apache.servicemix.demo.camel-jms-jdbc-xa-tx.datasource 53 | osgi.blueprint.container.version = 1.0.0 54 | service.id = 416 55 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/datasource/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.apache.camel.demo 25 | camel-jms-jdbc-xa 26 | 2.2.0 27 | 28 | 29 | org.apache.camel.demo.camel-jms-jdbc-xa 30 | datasource 31 | bundle 32 | Camel :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource 33 | 34 | 35 | 36 | org.apache.geronimo.components 37 | geronimo-connector 38 | 3.0 39 | 40 | 41 | 42 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.apache.felix 72 | maven-bundle-plugin 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/datasource/src/main/resources/OSGI-INF/blueprint/datasource.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 19 | 24 | 25 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/features/README.md: -------------------------------------------------------------------------------- 1 | # Features 2 | This project creates a features definition that can be used to easily install the example. 3 | 4 | ## How it works? 5 | Using Maven's resource filtering mechanism, we replace the `${xyz.version}` tokens in the `src/main/resources/features.xml` file. 6 | Afterwards, the resulting file is published as a Maven artifact itself so you can use it from within the Fuse ESB console with 7 | 8 | FuseESB:karaf@root> features:addurl mvn:org.apache.camel.demo.camel-jms-jdbc-xa-tx/features/2.1.0/xml/features 9 | 10 | Inside the features file, you'll find a definition for feature called `camel-jms-jdbc-xa-demo`. 11 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/features/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.apache.camel.demo 25 | camel-jms-jdbc-xa 26 | 2.2.0 27 | 28 | 29 | org.apache.camel.demo.camel-jms-jdbc-xa 30 | features 31 | pom 32 | Camel :: Demo :: Camel-JMS-JDBC-XA-TX :: Features 33 | 34 | 35 | 36 | 37 | src/main/resources 38 | true 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-resources-plugin 45 | 46 | 47 | filter 48 | generate-resources 49 | 50 | resources 51 | 52 | 53 | 54 | 55 | 56 | org.codehaus.mojo 57 | build-helper-maven-plugin 58 | 1.7 59 | 60 | 61 | attach-artifact 62 | package 63 | 64 | attach-artifact 65 | 66 | 67 | 68 | 69 | target/classes/features.xml 70 | xml 71 | features 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/features/src/main/resources/features.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | connector 11 | mvn:org.apache.aries.transaction/org.apache.aries.transaction.jdbc/2.1.2 12 | mvn:org.apache.geronimo.specs/geronimo-j2ee-connector_1.5_spec/2.0.0 13 | 14 | 15 | wrap:mvn:mysql/mysql-connector-java/5.1.27 16 | 17 | 18 | camel-sql 19 | mvn:org.apache.camel/camel-jms/${camel.version} 20 | mvn:org.apache.camel/camel-jdbc/${camel.version} 21 | 22 | 23 | mvn:${project.groupId}/datasource/${project.version} 24 | mvn:${project.groupId}/routing/${project.version} 25 | 26 | 27 | 31 | 32 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | org.apache.camel.demo 6 | camel-jms-jdbc-xa 7 | 2.2.0 8 | Camel :: Demo :: Camel-JMS-JDBC-XA-TX 9 | pom 10 | 11 | 12 | 13 | 14 | 5.1.27 15 | 16 | 17 | 18 | 19 | 20 | 21 | org.jboss.fuse.bom 22 | jboss-fuse-parent 23 | 6.3.0.redhat-416 24 | pom 25 | import 26 | 27 | 28 | 29 | 30 | 31 | features 32 | datasource 33 | routing 34 | 35 | 36 | 37 | 38 | 39 | 40 | org.apache.felix 41 | maven-bundle-plugin 42 | 2.3.7 43 | true 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-compiler-plugin 48 | 3.0 49 | true 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/routing/README.md: -------------------------------------------------------------------------------- 1 | # Routing 2 | 3 | This project contains the actual Camel route definition and JMS endpoint configuration using 4 | OSGi blueprint configuration. 5 | 6 | That configuration is in 7 | src/main/resources/OSGI-INF/blueprint/camel-context.xml 8 | 9 | It defines two Camel route, one using the camel-jdbc component, the other 10 | using the camel-sql component. 11 | 12 | In order to fill in data into the SQL statement created by the camel-sql 13 | component, it requires an object array if more than one value is to be 14 | replaced in the SQL statement. 15 | 16 | In the routing step 17 | 18 | 19 | 4 values are inserted into the SQL statement, so an object array of 4 strings 20 | is required. The source of this Camel route however is a JMS endpoint which 21 | receives a single JMS message at a time. 22 | The idea here is that we assume a JMS TextMessage with a comma separated list of 23 | values and use a custom Camel converter to convert this TextMessage into an 24 | object array. 25 | This Camel converter class is defined in 26 | src/main/java/org/apache/servicemix/demo/camel_jms_jdbc_xa_demo/DemoJDBCConverter.java 27 | 28 | 29 | Perhaps also take a minute to study the configuration of the JMS component. 30 | Note the ConnectionFactory used is of type org.apache.activemq.pool.JcaPooledConnectionFactory. 31 | When using XA transactions and enlisting into the Aries transaction manager, 32 | then this ConnectionFactory is needed. In addition it needs to be configured 33 | for a unique name property as that name identifies the XA resource when Aries 34 | writes its transaction log file. 35 | 36 | The same unique name needs to be configured for ActiveMQResourceManager bean 37 | definition. The resource manager is called on startup and asks the broker for 38 | any outstanding transactions that are then to be committed or rolled back. 39 | 40 | Further please notice the cacheLevelName is set to CACHE_CONNECTION which is the 41 | recommendation for XA transactions. 42 | 43 | And finally notice the brokerURL property of the ActiveMQXAConnectionFactory uses 44 | the url failover:(tcp://localhost:61616)?jms.prefetchPolicy.all=1. Using a 45 | prefetch of just one message makes sense since we don't cache JMS sessions and 46 | JMS consumers at Spring level. So a new JMS consumer gets created for every new 47 | message that is to be consumed. If the default prefetch of 1000 was used we 48 | would potentially prefetch up to 1000 messages to each consumer although 49 | only one message is processed before the consumer is destroyed again 50 | (which rejects all remaining 999 messages). 51 | 52 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/routing/src/main/java/org/apache/camel/demo/camel_jms_jdbc_xa/TestProcessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.camel.demo.camel_jms_jdbc_xa; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | /** 12 | * Dummy Camel Processor that simulates msg processing. 13 | * Increments a static counter for each msgs received. 14 | * 15 | * Can also be used to raise an exception for every X msg 16 | * to illustrate how an exception causes the XA transaction to be rolled back. 17 | */ 18 | public class TestProcessor implements Processor { 19 | private static AtomicInteger counter = new AtomicInteger(0); 20 | 21 | // whether to simulate a processing error by raising an exception 22 | private boolean simulateProcessingError = false; 23 | 24 | // if simulateProcessingError=true, then throw exception 25 | // every errorAfterMsgs messages. 26 | private int errorAfterMsgs = 5; 27 | 28 | private Logger log = LoggerFactory.getLogger(TestProcessor.class); 29 | 30 | 31 | public void process(Exchange exchange) throws Exception { 32 | 33 | if (log.isTraceEnabled()) 34 | log.trace("starting to process messages."); 35 | 36 | // increment counter 37 | counter.incrementAndGet(); 38 | 39 | // should we simulate a processing error? 40 | if (simulateProcessingError) { 41 | if (counter.get() % errorAfterMsgs == 0) { 42 | throw new RuntimeException("Thrown from Camel Processor to simulate an exception in Camel route"); 43 | } 44 | } 45 | if (log.isTraceEnabled()) 46 | log.trace("Finished msg processing. Counter is at " + counter.get()); 47 | } 48 | 49 | 50 | /* Getter and Setter methods */ 51 | public boolean isSimulateProcessingError() { 52 | return simulateProcessingError; 53 | } 54 | 55 | 56 | public void setSimulateProcessingError(boolean simulateProcessingError) { 57 | this.simulateProcessingError = simulateProcessingError; 58 | } 59 | 60 | public int getErrorAfterMsgs() { 61 | return errorAfterMsgs; 62 | } 63 | 64 | 65 | public void setErrorAfterMsgs(int errorAfterMsgs) { 66 | this.errorAfterMsgs = errorAfterMsgs; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC-XA-TX/routing/src/main/resources/META-INF/services/org/apache/camel/TypeConverter: -------------------------------------------------------------------------------- 1 | org.apache.camel.demo.camel_jms_jdbc_xa 2 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/datasource/README.md: -------------------------------------------------------------------------------- 1 | # Datasource bundle 2 | This bundle defines the JDBC `DataSource`s that will be used for accessing the 3 | relational database. 4 | 5 | 6 | ## Blueprint 7 | We are using Blueprint to define the data source bean and publish it into the OSGi Service Registry. Have a look at 8 | `src/main/resources/OSGI-INF/blueprint/datasource.xml` for more details about how this done. 9 | 10 | ## Checking the OSGi Service Registry 11 | After the bundle is started, we can use the Karaf console to look at the registered objects in the registry. 12 | 13 | First, find the bundle id for the bundle called " ESB :: Demo :: Camel-JMS-JDBC :: DataSource" by using the `osgi:list` command. 14 | You can use `grep` to filter the list of bundles and quickly find the right one. 15 | 16 | FuseESB:karaf@root> osgi:list | grep Camel-JMS-JDBC 17 | [ 268] [Active ] [Created ] [ ] [ 60] ESB :: Demo :: Camel-JMS-JDBC :: DataSource (2.0.0) 18 | [ 269] [Active ] [ ] [Started] [ 60] ESB :: Demo :: Camel-JMS-JDBC :: Routing (2.0.0) 19 | 20 | In this example, the bundle id is 268. Using the `osgi:ls` command, we can see that this bundle is publishing this DataSource as an OSGi service: 21 | This is what the `osgi:ls` output looks like 22 | 23 | Camel :: Demo :: Camel-JMS-JDBC:: DataSource (268) provides: 24 | ------------------------------------------------------------ 25 | datasource.name = DerbyDS 26 | objectClass = [javax.sql.DataSource] 27 | osgi.service.blueprint.compname = derby-ds 28 | service.id = 621 29 | service.ranking = 5 30 | ---- 31 | objectClass = org.osgi.service.blueprint.container.BlueprintContainer 32 | osgi.blueprint.container.symbolicname = org.apache.camel.demo.camel-jms-jdbc.datasource 33 | osgi.blueprint.container.version = 2.0.0 34 | service.id = 622 35 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/datasource/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.apache.camel.demo 25 | camel-jms-jdbc 26 | 2.0.0 27 | 28 | 29 | org.apache.camel.demo.camel-jms-jdbc 30 | datasource 31 | bundle 32 | Camel :: Demo :: Camel-JMS-JDBC:: DataSource 33 | 34 | 35 | 36 | org.apache.derby 37 | derby 38 | 10.10.1.1 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.felix 46 | maven-bundle-plugin 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/datasource/src/main/resources/OSGI-INF/blueprint/datasource.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 40 | 48 | 56 | 64 | 65 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/features/README.md: -------------------------------------------------------------------------------- 1 | # Features 2 | This project creates a features definition that can be used to easily install the example. 3 | 4 | ## How it works? 5 | Using Maven's resource filtering mechanism, we replace the `${xyz.version}` tokens in the `src/main/resources/features.xml` file. 6 | Afterwards, the resulting file is published as a Maven artifact itself so you can use it from the Karaf console with 7 | 8 | `karaf@root> features:addurl mvn:org.apache.servicemix.demo.camel-jms-jdbc/features/2.0.0/xml/features` 9 | 10 | Inside the features file, you'll find a definition for feature called `camel-jms-jdbc-demo`. -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/features/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.apache.camel.demo 25 | camel-jms-jdbc 26 | 2.0.0 27 | 28 | 29 | org.apache.camel.demo.camel-jms-jdbc 30 | features 31 | pom 32 | Camel :: Demo :: Camel-JMS-JDBC :: Features 33 | 34 | 35 | 36 | 37 | src/main/resources 38 | true 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-resources-plugin 45 | 46 | 47 | filter 48 | generate-resources 49 | 50 | resources 51 | 52 | 53 | 54 | 55 | 56 | org.codehaus.mojo 57 | build-helper-maven-plugin 58 | 1.7 59 | 60 | 61 | attach-artifact 62 | package 63 | 64 | attach-artifact 65 | 66 | 67 | 68 | 69 | target/classes/features.xml 70 | xml 71 | features 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/features/src/main/resources/features.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | mvn:org.apache.derby/derby/10.10.1.1 9 | wrap:mvn:commons-dbcp/commons-dbcp/1.4 10 | 11 | 12 | camel-sql 13 | mvn:org.apache.camel/camel-jms/${camel.version} 14 | mvn:org.apache.camel/camel-jdbc/${camel.version} 15 | 16 | 17 | wrap:mvn:${project.groupId}/routing/${project.version} 18 | mvn:${project.groupId}/datasource/${project.version} 19 | 20 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | org.apache.camel.demo 6 | camel-jms-jdbc 7 | 2.0.0 8 | Camel :: Demo :: Camel-JMS-JDBC 9 | pom 10 | 11 | 12 | 2.15.1.redhat-621084 13 | 5.11.0.redhat-621084 14 | 7.0.37 15 | 6.0.36 16 | 5.1.26 17 | 18 | 19 | 20 | features 21 | datasource 22 | routing 23 | 24 | 25 | 26 | 27 | 28 | 29 | org.apache.felix 30 | maven-bundle-plugin 31 | 2.3.7 32 | true 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-compiler-plugin 37 | 3.0 38 | true 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/routing/README.md: -------------------------------------------------------------------------------- 1 | # Routing 2 | 3 | This project contains the actual Camel route definitions and JMS endpoint configuration using 4 | OSGi blueprint configuration. 5 | 6 | That configuration is in 7 | `src/main/resources/OSGI-INF/blueprint/camel-context.xml` 8 | 9 | It defines two Camel routes, one using the camel-jdbc component, the other 10 | using the camel-sql component. 11 | 12 | In order to fill in data into the SQL statement created by the camel-sql 13 | component, it requires an object array if more than one value is to be 14 | replaced in the SQL statement. 15 | 16 | In the routing step 17 | `` 18 | 19 | 4 values are inserted into the SQL statement, so an object array of 4 strings 20 | is required. The source of this Camel route however is a JMS endpoint which 21 | receives a single JMS message at a time. 22 | The idea here is that we assume a JMS TextMessage with a comma separated list of 23 | values and use a custom Camel converter to convert this TextMessage into an 24 | object array. 25 | This Camel converter class is defined in 26 | `src/main/java/org/apache/servicemix/demo/camel_jms_jdbc_xa_demo/DemoJDBCConverter.java` 27 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/routing/src/main/java/org/apache/camel/demo/camel_jms_jdbc/TestProcessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.camel.demo.camel_jms_jdbc; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Processor; 7 | 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | /** 12 | * Dummy Camel Processor that simulates msg processing. 13 | * Increments a static counter for each msgs received. 14 | * 15 | * Can also be used to raise an exception for every X msg 16 | * to illustrate how an exception causes the XA transaction to be rolled back. 17 | */ 18 | public class TestProcessor implements Processor { 19 | private static AtomicInteger counter = new AtomicInteger(0); 20 | 21 | // whether to simulate a processing error by raising an exception 22 | private boolean simulateProcessingError = false; 23 | 24 | // if simulateProcessingError=true, then throw exception 25 | // every errorAfterMsgs messages. 26 | private int errorAfterMsgs = 5; 27 | 28 | private Logger log = LoggerFactory.getLogger(TestProcessor.class); 29 | 30 | 31 | public void process(Exchange exchange) throws Exception { 32 | 33 | if (log.isTraceEnabled()) 34 | log.trace("starting to process messages."); 35 | 36 | // increment counter 37 | counter.incrementAndGet(); 38 | 39 | // should we simulate a processing error? 40 | if (simulateProcessingError) { 41 | if (counter.get() % errorAfterMsgs == 0) { 42 | throw new RuntimeException("Thrown from Camel Processor to simulate an exception in Camel route"); 43 | } 44 | } 45 | if (log.isTraceEnabled()) 46 | log.trace("Finished msg processing. Counter is at " + counter.get()); 47 | } 48 | 49 | 50 | /* Getter and Setter methods */ 51 | public boolean isSimulateProcessingError() { 52 | return simulateProcessingError; 53 | } 54 | 55 | 56 | public void setSimulateProcessingError(boolean simulateProcessingError) { 57 | this.simulateProcessingError = simulateProcessingError; 58 | } 59 | 60 | public int getErrorAfterMsgs() { 61 | return errorAfterMsgs; 62 | } 63 | 64 | 65 | public void setErrorAfterMsgs(int errorAfterMsgs) { 66 | this.errorAfterMsgs = errorAfterMsgs; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-JDBC/routing/src/main/resources/META-INF/services/org/apache/camel/TypeConverter: -------------------------------------------------------------------------------- 1 | org.apache.camel.demo.camel_jms_jdbc 2 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-LocalTX/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ## --------------------------------------------------------------------------- 2 | ## Licensed to the Apache Software Foundation (ASF) under one or more 3 | ## contributor license agreements. See the NOTICE file distributed with 4 | ## this work for additional information regarding copyright ownership. 5 | ## The ASF licenses this file to You under the Apache License, Version 2.0 6 | ## (the "License"); you may not use this file except in compliance with 7 | ## the License. You may obtain a copy of the License at 8 | ## 9 | ## http://www.apache.org/licenses/LICENSE-2.0 10 | ## 11 | ## Unless required by applicable law or agreed to in writing, software 12 | ## distributed under the License is distributed on an "AS IS" BASIS, 13 | ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ## See the License for the specific language governing permissions and 15 | ## limitations under the License. 16 | ## --------------------------------------------------------------------------- 17 | 18 | # 19 | # The logging properties used during tests.. 20 | # 21 | log4j.rootLogger=INFO, out 22 | #log4j.logger.org.apache.activemq.spring=WARN 23 | log4j.logger.org.apache.camel.impl.converter=INFO 24 | #log4j.logger.org.apache.camel.management=WARN 25 | log4j.logger.org.springframework=INFO 26 | #log4j.logger.org.springframework.jms.connection.JmsTransactionManager=TRACE 27 | #log4j.logger.org.apache.activemq.pool.PooledConnectionFactory=TRACE 28 | #log4j.logger.org.apache.camel.spring.spi.SpringTransactionPolicy=TRACE 29 | log4j.logger.com.fusesource.support.TestProcessor=DEBUG 30 | 31 | 32 | # CONSOLE appender not used by default 33 | log4j.appender.out=org.apache.log4j.ConsoleAppender 34 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 35 | log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 36 | -------------------------------------------------------------------------------- /Camel/Camel-JMS-XA-TX/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | ## --------------------------------------------------------------------------- 2 | ## Licensed to the Apache Software Foundation (ASF) under one or more 3 | ## contributor license agreements. See the NOTICE file distributed with 4 | ## this work for additional information regarding copyright ownership. 5 | ## The ASF licenses this file to You under the Apache License, Version 2.0 6 | ## (the "License"); you may not use this file except in compliance with 7 | ## the License. You may obtain a copy of the License at 8 | ## 9 | ## http://www.apache.org/licenses/LICENSE-2.0 10 | ## 11 | ## Unless required by applicable law or agreed to in writing, software 12 | ## distributed under the License is distributed on an "AS IS" BASIS, 13 | ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ## See the License for the specific language governing permissions and 15 | ## limitations under the License. 16 | ## --------------------------------------------------------------------------- 17 | 18 | # 19 | # The logging properties used during tests.. 20 | # 21 | log4j.rootLogger=INFO, out 22 | #log4j.logger.org.apache.activemq.spring=WARN 23 | log4j.logger.org.apache.camel.impl.converter=INFO 24 | #log4j.logger.org.apache.camel.management=WARN 25 | log4j.logger.org.springframework=INFO 26 | #log4j.logger.org.springframework.jms.connection.JmsTransactionManager=TRACE 27 | #log4j.logger.org.apache.activemq.pool.PooledConnectionFactory=TRACE 28 | #log4j.logger.org.apache.camel.spring.spi.SpringTransactionPolicy=TRACE 29 | log4j.logger.com.fusesource.support.TestProcessor=DEBUG 30 | 31 | 32 | # CONSOLE appender not used by default 33 | log4j.appender.out=org.apache.log4j.ConsoleAppender 34 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 35 | log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 36 | -------------------------------------------------------------------------------- /Camel/Camel-Jetty-Basic-Auth-Demo/readme.md: -------------------------------------------------------------------------------- 1 | # Camel Jetty Basic Authentication Demo 2 | 3 | Tested against JBoss Fuse 6.1 4 | 5 | ## Description 6 | 7 | This demo programmatically configures a camel-jetty endpoint for HTTP Basic Authentication against the JAAS 8 | authentication realm provided by the Karaf OSGi container. That authentication realm is called 'karaf'. 9 | 10 | The configuration that is applied here programmatically is taken from this documentation 11 | https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.1/html/Security_Guide/files/CamelJetty.html 12 | 13 | 14 | 15 | 16 | 17 | 18 | ## Compiling 19 | 20 | simply run `mvn clean install` to build the demo. 21 | 22 | 23 | 24 | ## Deploying 25 | 26 | - open `$KARAF_HOME/etc/users.properties` and define a user with password and role. 27 | - start JBoss Fuse 6.1 28 | - install the following two bundles: 29 | `install -s mvn:org.apache.camel/camel-core-osgi/2.12.0.redhat-610379` 30 | `install -s mvn:org.apache.camel.demo/camel-jetty-basic-auth/1.0-SNAPSHOT` 31 | 32 | 33 | 34 | ## Running 35 | 36 | Once these two bundles are deployed and started successfully, point your browser to 37 | `http://localhost:9081/jettyexample` and you will be required to provide username and password credentials using 38 | HTTP basic authentication. Provide the same credentials that you initially entered into 39 | `$KARAF_HOME/etc/users.properties`. 40 | 41 | 42 | If authentication succeeds, the returned HTML will simply contain the word `response`. -------------------------------------------------------------------------------- /Camel/Camel-Jetty-Basic-Auth-Demo/src/main/java/org/apache/camel/demo/camel_jetty_basic_auth/JettyExampleRoute.java: -------------------------------------------------------------------------------- 1 | package org.apache.camel.demo.camel_jetty_basic_auth; 2 | 3 | import org.apache.camel.builder.RouteBuilder; 4 | 5 | public class JettyExampleRoute extends RouteBuilder { 6 | 7 | @Override 8 | public void configure() throws Exception { 9 | from("jetty:http://0.0.0.0:9081/jettyexample?handlers=securityHandler") 10 | .routeId("jettyexampleroute") 11 | .wireTap("log:something") 12 | .setBody(simple("Response from Camel.")); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Camel/Camel-Jetty-Basic-Auth-Demo/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # The logging properties used 3 | # 4 | log4j.rootLogger=INFO, out 5 | 6 | # uncomment the following line to turn on Camel debugging 7 | log4j.logger.org.apache.camel=DEBUG 8 | 9 | # CONSOLE appender not used by default 10 | log4j.appender.out=org.apache.log4j.ConsoleAppender 11 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 12 | log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n 13 | #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 14 | 15 | -------------------------------------------------------------------------------- /Camel/Camel-Jetty-Client-IP/README.md: -------------------------------------------------------------------------------- 1 | 2 | #CamelJettyHeaderTest 3 | 4 | Simple Camel JUnit test that shows how to extract the client's IP address 5 | in a Camel route that consumes from a Jetty HTTP endpoint. 6 | 7 | Although the camel-jetty endpoint does not expose the client's IP address 8 | as a message headers, it is possible to retrieve Jetty's HttpServletRequest 9 | object. This contains the complete client address information. 10 | 11 | The Camel route definition in src/main/resources/META-INF/spring/camel-context.xml 12 | is very simple: 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | The SimpleProcessor in src/main/java/org/apache/camel/test/SimpleProcessor 25 | extracts the client's IP address using these few lines of code: 26 | 27 | HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class); 28 | String remoteAddr = req.getRemoteAddr(); 29 | int remotePort = req.getRemotePort(); 30 | LOG.info("Client called from " + remoteAddr + ":" + remotePort); 31 | 32 | Finally the JUnit test class is located in 33 | src/test/java/org/apache/camel/test/JettyHeaderTest 34 | 35 | 36 | ##Compiling 37 | Simply run mvn test-compile to build the project 38 | 39 | 40 | ##Running 41 | There are two ways to run the demo. 42 | 43 | ###1) JUnit test 44 | Simply run mvn test and observe the logging output 45 | 46 | 47 | ###2) Camel Maven plugin 48 | Run mvn camel:run and wait for the route to be started. 49 | Then open your favorite browser and navigate to 50 | http://localhost:9000/JettyHeaderTest 51 | 52 | The reply displayed in your browser should read: 53 | 54 | Camel Route Reply 55 | You called from address 127.0.0.1:59524 with data: null 56 | -------------------------------------------------------------------------------- /Camel/Camel-Jetty-Client-IP/src/main/java/org/apache/camel/test/SimpleProcessor.java: -------------------------------------------------------------------------------- 1 | package org.apache.camel.test; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.apache.camel.Exchange; 6 | import org.apache.camel.Message; 7 | import org.apache.camel.Processor; 8 | 9 | import org.slf4j.LoggerFactory; 10 | import org.slf4j.Logger; 11 | 12 | /** 13 | * Tries to extract the TCP address of the remote client from 14 | * the exchange. This address is not exposed as a general header 15 | * on the incoming message. Instead it tries to extract the original 16 | * Jetty HttpServletRequest, which has all the client information. 17 | * This processor can only be used in combination with a camel-jetty consumer! 18 | * 19 | * @author tmielke 20 | */ 21 | public class SimpleProcessor implements Processor{ 22 | 23 | protected final static Logger LOG = LoggerFactory.getLogger(SimpleProcessor.class); 24 | 25 | public void process(Exchange exchange) { 26 | String reply = "

Camel Route Reply


"; 27 | LOG.debug("SimpleProcessor.checkHeader() invoked."); 28 | Message inMsg = exchange.getIn(); 29 | 30 | // extract the Jetty HttpServletRequest, from there we can extract 31 | // the remote client address. 32 | HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class); 33 | if (req != null) { 34 | String remoteAddr = req.getRemoteAddr(); 35 | int remotePort = req.getRemotePort(); 36 | LOG.info("Client called from " + remoteAddr + ":" + remotePort); 37 | 38 | // generate a reply message 39 | reply += "You called from address " + remoteAddr + ":" + remotePort + 40 | " with data: " + inMsg.getBody() + ""; 41 | } else { 42 | reply = "Could not extract client address!"; 43 | } 44 | exchange.getOut().setBody(reply); 45 | } 46 | } -------------------------------------------------------------------------------- /Camel/Camel-Jetty-Client-IP/src/main/resources/META-INF/spring/camel-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Camel/Camel-Jetty-Client-IP/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, file, out 2 | 3 | # File Appender ############################################## 4 | log4j.appender.file=org.apache.log4j.RollingFileAppender 5 | log4j.appender.file.File=target/test.log 6 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 7 | log4j.appender.file.layout.ConversionPattern=%d %-2p [%t] %c{3} - %m - %n 8 | 9 | #Console Appender ############################################ 10 | log4j.appender.out=org.apache.log4j.ConsoleAppender 11 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 12 | log4j.appender.out.layout.ConversionPattern=%d %p %t - %m%n 13 | 14 | log4j.logger.org.apache.camel.test=DEBUG 15 | 16 | # With regards to ConversionPattern, here is a description 17 | #%c = category %F = current file %m = message 18 | #%d = date %L = current line %t = thread 19 | #%p = priority %M = current method %n = newline 20 | 21 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX-JBossFuse6.0/features/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.apache.camel.demo 25 | camel-wmq-amq-xa-tx 26 | 1.0.0 27 | 28 | 29 | org.apache.camel.demo.camel-wmq-amq-xa-tx 30 | features 31 | pom 32 | Camel :: Demo :: Camel-WMQ-AMQ-XA-TX :: Features 33 | 34 | 35 | 36 | 37 | src/main/resources 38 | true 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-resources-plugin 45 | 46 | 47 | filter 48 | generate-resources 49 | 50 | resources 51 | 52 | 53 | 54 | 55 | 56 | org.codehaus.mojo 57 | build-helper-maven-plugin 58 | 1.7 59 | 60 | 61 | attach-artifact 62 | package 63 | 64 | attach-artifact 65 | 66 | 67 | 68 | 69 | target/classes/features.xml 70 | xml 71 | features 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX-JBossFuse6.0/kill-script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script that periodically kills the SMX instance during a load test. 3 | # Script runs a fixed number of times 4 | 5 | sleepTime=120 6 | iterations=10 7 | 8 | echo "Going to kill SMX $iterations times" 9 | 10 | i=0 11 | while [ $i -lt "$iterations" ] ; do 12 | pid=`jps -l -m | grep "org.apache.karaf.main.Main" | cut -c1-6` 13 | echo "Killing ESB instance with pid $pid. Counter is at $i." 14 | kill -9 $pid 15 | echo "Sleeping $sleepTime seconds" 16 | sleep $sleepTime 17 | i=`echo $i+1 | bc` 18 | done 19 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX-JBossFuse6.0/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | org.apache.camel.demo 7 | camel-wmq-amq-xa-tx 8 | 1.0.0 9 | Camel :: Demo :: Camel-WMQ-AMQ-XA-TX 10 | pom 11 | 12 | 13 | 2.10.0.fuse-71-047 14 | 5.8.0.redhat-60024 15 | 16 | 17 | 18 | features 19 | routing 20 | 21 | 22 | 23 | 24 | fusesource.release 25 | FuseSource Release Repo 26 | http://repo.fusesource.com/nexus/content/groups/public/ 27 | 28 | true 29 | 30 | 31 | false 32 | 33 | 34 | 35 | 36 | 37 | fusesource.release 38 | FuseSource Release Repo 39 | http://repo.fusesource.com/nexus/content/groups/public/ 40 | 41 | true 42 | 43 | 44 | false 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.felix 53 | maven-bundle-plugin 54 | 2.3.7 55 | true 56 | 57 | 58 | org.apache.maven.plugins 59 | maven-compiler-plugin 60 | 3.0 61 | true 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX-JBossFuse6.0/routing/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.apache.camel.demo 8 | camel-wmq-amq-xa-tx 9 | 1.0.0 10 | 11 | 12 | org.apache.camel.demo.camel-wmq-amq-xa-tx 13 | routing 14 | 1.0.0 15 | Camel :: Demo :: Camel-WMQ-AMQ-XA-TX :: Routing 16 | bundle 17 | 18 | 19 | 20 | * 21 | 22 | 23 | org.apache.camel.demo.camel_wmq_amq_xa_tx, 24 | org.springframework.jms.connection.xa 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.apache.camel 33 | camel-core 34 | ${camel.version} 35 | 36 | 37 | org.apache.camel 38 | camel-spring 39 | ${camel.version} 40 | 41 | 42 | org.apache.activemq 43 | activemq-client 44 | ${activemq.version} 45 | 46 | 47 | org.apache.activemq 48 | activemq-pool 49 | ${activemq.version} 50 | 51 | 52 | org.springframework 53 | spring-jms 54 | 3.2.4.RELEASE 55 | jar 56 | compile 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.apache.felix 64 | maven-bundle-plugin 65 | true 66 | 67 | 68 | ${servicemix.osgi.export} 69 | ${servicemix.osgi.import} 70 | ${servicemix.osgi.bundles} 71 | ${servicemix.osgi.dynamic.import} 72 | ${servicemix.osgi.private} 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX-JBossFuse6.0/routing/src/main/java/org/apache/camel/demo/camel_wmq_amq_xa_tx/TestProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.apache.camel.demo.camel_wmq_amq_xa_tx; 17 | 18 | import java.util.concurrent.atomic.AtomicInteger; 19 | 20 | import org.apache.camel.Exchange; 21 | import org.apache.camel.Processor; 22 | 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | 27 | /** 28 | * Dummy Camel Processor that simulates msg processing. 29 | * Increments a static counter for each msgs received. 30 | * 31 | * Can also be used to raise an exception for every X msg 32 | * to illustrate how an exception causes the transaction to be rolled 33 | * back. 34 | * 35 | */ 36 | public class TestProcessor implements Processor { 37 | private static AtomicInteger counter = new AtomicInteger(0); 38 | 39 | // whether to simulate a processing error by raising an exception 40 | private boolean simulateProcessingError = false; 41 | 42 | // if simulateProcessingError=true, then throw exception 43 | // every errorAfterMsgs messages. 44 | private int errorAfterMsgs = 5; 45 | 46 | private Logger log = LoggerFactory.getLogger(TestProcessor.class); 47 | 48 | 49 | public void process(Exchange exchange) throws Exception { 50 | 51 | if (log.isTraceEnabled()) 52 | log.trace("starting to process messages."); 53 | 54 | // increment counter 55 | counter.incrementAndGet(); 56 | 57 | // should we simulate a processing error? 58 | if (simulateProcessingError) { 59 | if (counter.get() % errorAfterMsgs == 0) { 60 | throw new RuntimeException("Thrown from Camel Processor to simulate an exception in Camel route"); 61 | } 62 | } 63 | 64 | if (log.isTraceEnabled()) 65 | log.trace("Finished msg processing. Counter is at " + counter.get()); 66 | } 67 | 68 | 69 | /* Getter and Setter methods */ 70 | public boolean isSimulateProcessingError() { 71 | return simulateProcessingError; 72 | } 73 | 74 | 75 | public void setSimulateProcessingError(boolean simulateProcessingError) { 76 | this.simulateProcessingError = simulateProcessingError; 77 | } 78 | 79 | 80 | public int getErrorAfterMsgs() { 81 | return errorAfterMsgs; 82 | } 83 | 84 | 85 | public void setErrorAfterMsgs(int errorAfterMsgs) { 86 | this.errorAfterMsgs = errorAfterMsgs; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX/features/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 20 | 21 | 4.0.0 22 | 23 | 24 | org.apache.camel.demo 25 | camel-wmq-amq-xa-tx 26 | 1.0.0 27 | 28 | 29 | org.apache.camel.demo.camel-wmq-amq-xa-tx 30 | features 31 | pom 32 | Camel :: Demo :: Camel-WMQ-AMQ-XA-TX :: Features 33 | 34 | 35 | 36 | 37 | src/main/resources 38 | true 39 | 40 | 41 | 42 | 43 | org.apache.maven.plugins 44 | maven-resources-plugin 45 | 46 | 47 | filter 48 | generate-resources 49 | 50 | resources 51 | 52 | 53 | 54 | 55 | 56 | org.codehaus.mojo 57 | build-helper-maven-plugin 58 | 1.7 59 | 60 | 61 | attach-artifact 62 | package 63 | 64 | attach-artifact 65 | 66 | 67 | 68 | 69 | target/classes/features.xml 70 | xml 71 | features 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX/kill-script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Script that periodically kills the SMX instance during a load test. 3 | # Script runs a fixed number of times 4 | 5 | sleepTime=120 6 | iterations=10 7 | 8 | echo "Going to kill SMX $iterations times" 9 | 10 | i=0 11 | while [ $i -lt "$iterations" ] ; do 12 | pid=`jps -l -m | grep "org.apache.karaf.main.Main" | cut -c1-6` 13 | echo "Killing ESB instance with pid $pid. Counter is at $i." 14 | kill -9 $pid 15 | echo "Sleeping $sleepTime seconds" 16 | sleep $sleepTime 17 | i=`echo $i+1 | bc` 18 | done 19 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | org.apache.camel.demo 7 | camel-wmq-amq-xa-tx 8 | 1.0.0 9 | Camel :: Demo :: Camel-WMQ-AMQ-XA-TX 10 | pom 11 | 12 | 13 | 2.10.0.fuse-71-047 14 | 5.8.0.redhat-60024 15 | 16 | 17 | 18 | features 19 | routing 20 | 21 | 22 | 23 | 24 | fusesource.release 25 | FuseSource Release Repo 26 | http://repo.fusesource.com/nexus/content/groups/public/ 27 | 28 | true 29 | 30 | 31 | false 32 | 33 | 34 | 35 | 36 | 37 | fusesource.release 38 | FuseSource Release Repo 39 | http://repo.fusesource.com/nexus/content/groups/public/ 40 | 41 | true 42 | 43 | 44 | false 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.felix 53 | maven-bundle-plugin 54 | 2.3.7 55 | true 56 | 57 | 58 | org.apache.maven.plugins 59 | maven-compiler-plugin 60 | 3.0 61 | true 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX/routing/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | 7 | org.apache.camel.demo 8 | camel-wmq-amq-xa-tx 9 | 1.0.0 10 | 11 | 12 | org.apache.camel.demo.camel-wmq-amq-xa-tx 13 | routing 14 | 1.0.0 15 | Camel :: Demo :: Camel-WMQ-AMQ-XA-TX :: Routing 16 | bundle 17 | 18 | 19 | 20 | * 21 | 22 | 23 | org.apache.camel.demo.camel_wmq_amq_xa_tx, 24 | org.springframework.jms.connection.xa 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.springframework 33 | spring-jms 34 | 3.2.8.RELEASE 35 | 36 | 37 | 38 | org.apache.camel 39 | camel-core 40 | ${camel.version} 41 | 42 | 43 | org.apache.camel 44 | camel-spring 45 | ${camel.version} 46 | 47 | 48 | org.apache.activemq 49 | activemq-client 50 | ${activemq.version} 51 | 52 | 53 | org.apache.activemq 54 | activemq-pool 55 | ${activemq.version} 56 | 57 | 58 | org.springframework 59 | spring-jms 60 | 3.2.4.RELEASE 61 | jar 62 | compile 63 | 64 | 65 | 66 | 67 | 68 | 69 | org.apache.felix 70 | maven-bundle-plugin 71 | true 72 | 73 | 74 | ${servicemix.osgi.export} 75 | ${servicemix.osgi.import} 76 | ${servicemix.osgi.bundles} 77 | ${servicemix.osgi.dynamic.import} 78 | ${servicemix.osgi.private} 79 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Camel/Camel-WMQ-AMQ-XA-TX/routing/src/main/java/org/apache/camel/demo/camel_wmq_amq_xa_tx/TestProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Red Hat, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.apache.camel.demo.camel_wmq_amq_xa_tx; 17 | 18 | import java.util.concurrent.atomic.AtomicInteger; 19 | 20 | import org.apache.camel.Exchange; 21 | import org.apache.camel.Processor; 22 | 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | 27 | /** 28 | * Dummy Camel Processor that simulates msg processing. 29 | * Increments a static counter for each msgs received. 30 | * 31 | * Can also be used to raise an exception for every X msg 32 | * to illustrate how an exception causes the transaction to be rolled 33 | * back. 34 | * 35 | */ 36 | public class TestProcessor implements Processor { 37 | private static AtomicInteger counter = new AtomicInteger(0); 38 | 39 | // whether to simulate a processing error by raising an exception 40 | private boolean simulateProcessingError = false; 41 | 42 | // if simulateProcessingError=true, then throw exception 43 | // every errorAfterMsgs messages. 44 | private int errorAfterMsgs = 5; 45 | 46 | private Logger log = LoggerFactory.getLogger(TestProcessor.class); 47 | 48 | 49 | public void process(Exchange exchange) throws Exception { 50 | 51 | if (log.isTraceEnabled()) 52 | log.trace("starting to process messages."); 53 | 54 | // increment counter 55 | counter.incrementAndGet(); 56 | 57 | // should we simulate a processing error? 58 | if (simulateProcessingError) { 59 | if (counter.get() % errorAfterMsgs == 0) { 60 | throw new RuntimeException("Thrown from Camel Processor to simulate an exception in Camel route"); 61 | } 62 | } 63 | 64 | if (log.isTraceEnabled()) 65 | log.trace("Finished msg processing. Counter is at " + counter.get()); 66 | } 67 | 68 | 69 | /* Getter and Setter methods */ 70 | public boolean isSimulateProcessingError() { 71 | return simulateProcessingError; 72 | } 73 | 74 | 75 | public void setSimulateProcessingError(boolean simulateProcessingError) { 76 | this.simulateProcessingError = simulateProcessingError; 77 | } 78 | 79 | 80 | public int getErrorAfterMsgs() { 81 | return errorAfterMsgs; 82 | } 83 | 84 | 85 | public void setErrorAfterMsgs(int errorAfterMsgs) { 86 | this.errorAfterMsgs = errorAfterMsgs; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/client/src/main/java/sample/camel/ClientApplication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package sample.camel; 18 | 19 | import javax.enterprise.event.Observes; 20 | 21 | import org.apache.camel.cdi.ContextName; 22 | import org.apache.camel.management.event.CamelContextStartingEvent; 23 | import org.apache.camel.zipkin.ZipkinTracer; 24 | import com.github.kristofa.brave.http.HttpSpanCollector; 25 | import com.github.kristofa.brave.EmptySpanCollectorMetricsHandler; 26 | 27 | @ContextName("Server1") 28 | public class ClientApplication { 29 | 30 | public void setupCamel(@Observes CamelContextStartingEvent event) { 31 | 32 | // create zipkin 33 | ZipkinTracer zipkin = new ZipkinTracer(); 34 | 35 | // URL of Zipkin server 36 | //zipkin.setEndpoint("http://localhost:9411/api/v2/spans"); 37 | 38 | // for talking to Hawkular 39 | zipkin.setEndpoint("http://localhost:8080/api/v1/spans"); 40 | zipkin.setIncludeMessageBody(true); 41 | zipkin.setIncludeMessageBodyStreams(true); 42 | zipkin.setSpanCollector(HttpSpanCollector.create("http://localhost:8080", new EmptySpanCollectorMetricsHandler())); 43 | // end of talking to Hawkular 44 | 45 | zipkin.addClientServiceMapping("http://localhost:9090/service1", "service1"); 46 | // capture 100% of all the events 47 | zipkin.setRate(1.0f); 48 | // include message bodies in the traces (not recommended for production) 49 | zipkin.setIncludeMessageBodyStreams(true); 50 | 51 | // register zipkin to CamelContext 52 | zipkin.init(event.getContext()); 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/client/src/main/java/sample/camel/ClientRoute.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package sample.camel; 18 | 19 | import org.apache.camel.builder.RouteBuilder; 20 | 21 | public class ClientRoute extends RouteBuilder { 22 | 23 | @Override 24 | public void configure() { 25 | // you can configure the route rule with Java DSL here 26 | from("timer:trigger?exchangePattern=InOut&period=10s").streamCaching() 27 | .bean("counterBean") 28 | .log(" Client request: ${body}") 29 | .to("http://localhost:9090/service1") 30 | .log("Client response: ${body}"); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/client/src/main/java/sample/camel/CounterBean.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package sample.camel; 18 | 19 | import javax.inject.Named; 20 | import javax.inject.Singleton; 21 | 22 | @Singleton 23 | @Named("counterBean") 24 | public class CounterBean { 25 | 26 | private int counter; 27 | 28 | public String someMethod(String body) { 29 | return "" + ++counter; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/client/src/main/resources/META-INF/NOTICE.txt: -------------------------------------------------------------------------------- 1 | ========================================================================= 2 | == NOTICE file corresponding to the section 4 d of == 3 | == the Apache License, Version 2.0, == 4 | == in this case for the Apache Camel distribution. == 5 | ========================================================================= 6 | 7 | This product includes software developed by 8 | The Apache Software Foundation (http://www.apache.org/). 9 | 10 | Please read the different LICENSE files present in the licenses directory of 11 | this distribution. 12 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/client/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/client/src/main/resources/log4j2.properties: -------------------------------------------------------------------------------- 1 | ## --------------------------------------------------------------------------- 2 | ## Licensed to the Apache Software Foundation (ASF) under one or more 3 | ## contributor license agreements. See the NOTICE file distributed with 4 | ## this work for additional information regarding copyright ownership. 5 | ## The ASF licenses this file to You under the Apache License, Version 2.0 6 | ## (the "License"); you may not use this file except in compliance with 7 | ## the License. You may obtain a copy of the License at 8 | ## 9 | ## http://www.apache.org/licenses/LICENSE-2.0 10 | ## 11 | ## Unless required by applicable law or agreed to in writing, software 12 | ## distributed under the License is distributed on an "AS IS" BASIS, 13 | ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ## See the License for the specific language governing permissions and 15 | ## limitations under the License. 16 | ## --------------------------------------------------------------------------- 17 | 18 | appender.stdout.type = Console 19 | appender.stdout.name = stdout 20 | appender.stdout.layout.type = PatternLayout 21 | appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n 22 | logger.zipkin.name = org.apache.camel.zipkin 23 | logger.zipkin.level = DEBUG 24 | rootLogger.level = INFO 25 | rootLogger.appenderRef.stdout.ref = stdout 26 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/images/zipkin-web-console-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmielke/fuse-demos/9020e75ddf6970a4f226e2fb724947a05160b493/Camel/Camel-Zipkin-Hawkular/images/zipkin-web-console-1.png -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/images/zipkin-web-console-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tmielke/fuse-demos/9020e75ddf6970a4f226e2fb724947a05160b493/Camel/Camel-Zipkin-Hawkular/images/zipkin-web-console-2.png -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 4.0.0 23 | 24 | 25 | org.apache.camel 26 | camel-parent 27 | 2.21.0 28 | 29 | 30 | org.apache.camel.example 31 | camel-example-zipkin-hawkular 32 | 2.21.0 33 | pom 34 | Camel :: Example :: Zipkin 35 | An example showing how to trace incoming and outgoing messages from Camel with Zipkin to Hawkular 36 | 37 | 38 | Management and Monitoring 39 | 40 | 41 | 42 | client 43 | service1 44 | service2 45 | 46 | 47 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/service1/src/main/java/sample/camel/Service1Application.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package sample.camel; 18 | 19 | import org.apache.camel.zipkin.starter.CamelZipkin; 20 | import org.apache.camel.CamelContext; 21 | import org.apache.camel.zipkin.ZipkinTracer; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.boot.SpringApplication; 24 | import org.springframework.boot.autoconfigure.SpringBootApplication; 25 | 26 | // import com.github.kristofa.brave.http.HttpSpanCollector; 27 | // import com.github.kristofa.brave.EmptySpanCollectorMetricsHandler; 28 | 29 | 30 | /** 31 | * A Spring Boot application that starts the Camel Zipkin application. 32 | *

33 | * Notice we use the `@CamelZipkin` annotation to enable Camel with Zipkin. 34 | * The configuration of Zipkin is in the application.properties file. 35 | */ 36 | @SpringBootApplication 37 | @CamelZipkin 38 | public class Service1Application { 39 | 40 | /** 41 | * A main method to start this application. 42 | */ 43 | public static void main(String[] args) { 44 | 45 | SpringApplication.run(Service1Application.class, args); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/service1/src/main/java/sample/camel/Service1Route.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package sample.camel; 18 | 19 | import org.apache.camel.builder.RouteBuilder; 20 | import org.springframework.stereotype.Component; 21 | 22 | import org.apache.camel.builder.RouteBuilder; 23 | import org.apache.camel.zipkin.ZipkinTracer; 24 | 25 | //only needed when talking to Hawkular 26 | import com.github.kristofa.brave.http.HttpSpanCollector; 27 | import com.github.kristofa.brave.EmptySpanCollectorMetricsHandler; 28 | 29 | 30 | @Component 31 | public class Service1Route extends RouteBuilder { 32 | 33 | @Override 34 | public void configure() throws Exception { 35 | 36 | // create zipkin 37 | ZipkinTracer zipkin = new ZipkinTracer(); 38 | 39 | // for talking to Zipkin server 40 | // zipkin.setEndpoint("http://localhost:9411/api/v2/spans"); 41 | 42 | // for talking to Hawkular 43 | zipkin.setEndpoint("http://localhost:8080/api/v1/spans"); 44 | zipkin.setIncludeMessageBody(true); 45 | zipkin.setIncludeMessageBodyStreams(true); 46 | zipkin.addServerServiceMapping("http://localhost:7070/service2", "service2"); 47 | zipkin.setSpanCollector(HttpSpanCollector.create("http://localhost:8080", new EmptySpanCollectorMetricsHandler())); 48 | // end of talking to Hawkular 49 | 50 | // set the service name 51 | zipkin.setServiceName("service2"); 52 | // capture 100% of all the events 53 | zipkin.setRate(1.0f); 54 | // include message bodies in the traces (not recommended for production) 55 | zipkin.setIncludeMessageBodyStreams(true); 56 | 57 | // add zipkin to CamelContext 58 | zipkin.init(getContext()); 59 | 60 | from("jetty:http://0.0.0.0:{{service1.port}}/service1").routeId("service1").streamCaching() 61 | .removeHeaders("CamelHttp*") 62 | .log("Service1 request: ${body}") 63 | .delay(simple("${random(1000,2000)}")) 64 | .transform(simple("Service1-${body}")) 65 | .to("http://0.0.0.0:{{service2.port}}/service2") 66 | .log("Service1 response: ${body}"); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/service1/src/main/resources/META-INF/NOTICE.txt: -------------------------------------------------------------------------------- 1 | ========================================================================= 2 | == NOTICE file corresponding to the section 4 d of == 3 | == the Apache License, Version 2.0, == 4 | == in this case for the Apache Camel distribution. == 5 | ========================================================================= 6 | 7 | This product includes software developed by 8 | The Apache Software Foundation (http://www.apache.org/). 9 | 10 | Please read the different LICENSE files present in the licenses directory of 11 | this distribution. 12 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/service1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | ## --------------------------------------------------------------------------- 2 | ## Licensed to the Apache Software Foundation (ASF) under one or more 3 | ## contributor license agreements. See the NOTICE file distributed with 4 | ## this work for additional information regarding copyright ownership. 5 | ## The ASF licenses this file to You under the Apache License, Version 2.0 6 | ## (the "License"); you may not use this file except in compliance with 7 | ## the License. You may obtain a copy of the License at 8 | ## 9 | ## http://www.apache.org/licenses/LICENSE-2.0 10 | ## 11 | ## Unless required by applicable law or agreed to in writing, software 12 | ## distributed under the License is distributed on an "AS IS" BASIS, 13 | ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ## See the License for the specific language governing permissions and 15 | ## limitations under the License. 16 | ## --------------------------------------------------------------------------- 17 | 18 | # the name of Camel 19 | camel.springboot.name=Service1 20 | camel.springboot.main-run-controller=true 21 | 22 | # There is explicit Zipkin configuration in Service1Route.java 23 | # the configuration here is not needed. 24 | # configure zipkin 25 | # URL of Zipkin server 26 | # camel.zipkin.endpoint=http://localhost:9411/api/v2/spans 27 | 28 | # URL of Hawkular server 29 | #camel.zipkin.endpoint=http://localhost:8080/api/v1/spans 30 | #camel.zipkin.include-message-body=true 31 | # end of Hawkular specific config 32 | 33 | # the zipkin service name 34 | camel.zipkin.server-service-mappings.*=service1 35 | camel.zipkin.client-service-mappings.*=service2 36 | 37 | # include message bodies in the traces (not recommended for production) 38 | camel.zipkin.include-message-body-streams=true 39 | 40 | # logging to see the zipkin traces 41 | logging.level.org.apache.camel.zipkin=debug 42 | 43 | # the port number the service will use for accepting incoming HTTP requests 44 | service1.port=9090 45 | service2.port=7070 46 | 47 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/service2/src/main/java/sample/camel/Service2Application.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package sample.camel; 18 | 19 | import org.apache.camel.main.Main; 20 | 21 | public final class Service2Application { 22 | 23 | private Service2Application() { 24 | // noop 25 | } 26 | 27 | public static void main(String[] args) throws Exception { 28 | Main main = new Main(); 29 | main.addRouteBuilder(new Service2Route()); 30 | main.run(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/service2/src/main/java/sample/camel/Service2Route.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package sample.camel; 18 | 19 | import org.apache.camel.builder.RouteBuilder; 20 | import org.apache.camel.zipkin.ZipkinTracer; 21 | 22 | //only needed when talking to Hawkular 23 | import com.github.kristofa.brave.http.HttpSpanCollector; 24 | import com.github.kristofa.brave.EmptySpanCollectorMetricsHandler; 25 | 26 | public class Service2Route extends RouteBuilder { 27 | 28 | @Override 29 | public void configure() throws Exception { 30 | 31 | // create zipkin 32 | ZipkinTracer zipkin = new ZipkinTracer(); 33 | 34 | // for talking to Zipkin server 35 | // zipkin.setEndpoint("http://localhost:9411/api/v2/spans"); 36 | 37 | // for talking to Hawkular 38 | zipkin.setEndpoint("http://localhost:8080/api/v1/spans"); 39 | zipkin.setIncludeMessageBody(true); 40 | zipkin.setIncludeMessageBodyStreams(true); 41 | zipkin.addServerServiceMapping("http://localhost:7070/service2", "service2"); 42 | zipkin.setSpanCollector(HttpSpanCollector.create("http://localhost:8080", new EmptySpanCollectorMetricsHandler())); 43 | // end of talking to Hawkular 44 | 45 | // set the service name 46 | zipkin.setServiceName("service2"); 47 | // capture 100% of all the events 48 | zipkin.setRate(1.0f); 49 | // include message bodies in the traces (not recommended for production) 50 | zipkin.setIncludeMessageBodyStreams(true); 51 | 52 | // add zipkin to CamelContext 53 | zipkin.init(getContext()); 54 | 55 | from("undertow:http://0.0.0.0:7070/service2").routeId("service2").streamCaching() 56 | .log(" Service2 request: ${body}") 57 | .delay(simple("${random(1000,2000)}")) 58 | .transform(simple("Service2-${body}")) 59 | .log("Service2 response: ${body}"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/service2/src/main/resources/META-INF/NOTICE.txt: -------------------------------------------------------------------------------- 1 | ========================================================================= 2 | == NOTICE file corresponding to the section 4 d of == 3 | == the Apache License, Version 2.0, == 4 | == in this case for the Apache Camel distribution. == 5 | ========================================================================= 6 | 7 | This product includes software developed by 8 | The Apache Software Foundation (http://www.apache.org/). 9 | 10 | Please read the different LICENSE files present in the licenses directory of 11 | this distribution. 12 | -------------------------------------------------------------------------------- /Camel/Camel-Zipkin-Hawkular/service2/src/main/resources/log4j2.properties: -------------------------------------------------------------------------------- 1 | ## --------------------------------------------------------------------------- 2 | ## Licensed to the Apache Software Foundation (ASF) under one or more 3 | ## contributor license agreements. See the NOTICE file distributed with 4 | ## this work for additional information regarding copyright ownership. 5 | ## The ASF licenses this file to You under the Apache License, Version 2.0 6 | ## (the "License"); you may not use this file except in compliance with 7 | ## the License. You may obtain a copy of the License at 8 | ## 9 | ## http://www.apache.org/licenses/LICENSE-2.0 10 | ## 11 | ## Unless required by applicable law or agreed to in writing, software 12 | ## distributed under the License is distributed on an "AS IS" BASIS, 13 | ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ## See the License for the specific language governing permissions and 15 | ## limitations under the License. 16 | ## --------------------------------------------------------------------------- 17 | 18 | appender.stdout.type = Console 19 | appender.stdout.name = stdout 20 | appender.stdout.layout.type = PatternLayout 21 | appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n 22 | logger.zipkin.name = org.apache.camel.zipkin 23 | logger.zipkin.level = DEBUG 24 | rootLogger.level = INFO 25 | rootLogger.appenderRef.stdout.ref = stdout 26 | -------------------------------------------------------------------------------- /Camel/README.md: -------------------------------------------------------------------------------- 1 | ## This directory contains Camel related demos 2 | 3 | ### Camel-Fabric-Master-Component/ 4 | uses the Camel Fabric master component to create an exclusive consumer endpoint 5 | 6 | 7 | ### Camel-HTTP-Proxy 8 | quick demo that show how to proxy HTTP requests. 9 | 10 | 11 | ### Camel-HornetQ-AMQ 12 | routes messages from an external HornetQ broker to an embedded ActiveMQ broker 13 | (non transactional) 14 | 15 | ### Camel-JMS-LocalTX 16 | consumes messages from one JMS broker and optionally routes to another JMS broker 17 | using local JMS transactions only. 18 | 19 | ### Camel-JMS-JDBC 20 | shows how to route messages in Camel from a JMS broker into a JDBC database. 21 | 22 | 23 | ### Camel-JMS-JDBC-XA-TX 24 | similar to above demo but using XA transactions. To be used on 25 | JBoss Fuse 6.1 or higher 26 | 27 | 28 | ### Camel-JMS-JDBC-XA-TX-JBossFuse6.0 29 | as above but specifically for JBoss Fuse 6.0 to workaround bug ENTESB-633 30 | https://issues.jboss.org/browse/ENTESB-633 31 | 32 | 33 | ### Camel-WMQ-AMQ-XA-TX 34 | shows how to route messages in Camel using XA transactions from WebSphere MQ 35 | to ActiveMQ. 36 | 37 | 38 | ## Camel-Jetty-Basic-Auth-Demo 39 | programmatically configures a camel-jetty endpoint for HTTP Basic Authentication 40 | against the JAAS authentication realm provided by the Karaf OSGi container. 41 | 42 | ### Camel-Jetty-Client-IP 43 | Is a simple Camel JUnit test that shows how to extract the client's IP address 44 | in a Camel route that consumes from a Jetty HTTP endpoint. 45 | 46 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/EJB-Client/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## EJB Client 3 | 4 | This directory contains the EJB client application. 5 | Its a standalone JBoss client that invokes a stateless session bean deployed 6 | in JBoss 5. 7 | 8 | The client can also be run standalone for sanity checking but the real value 9 | of this demo is to deploy this client into Fuse ESB. 10 | 11 | 12 | ### Standalone Client 13 | To run the client standalone follow these steps: 14 | 15 | ``` 16 | - Deploy the Simple-EJB into JBoss 5 as explained in ../README.md 17 | 18 | - edit create-uber-jar.sh and update JBOSS_HOME accordingly 19 | 20 | - run ./create-uber-jar.sh and verify it creates ./jboss-client-all.jar 21 | 22 | - run the standalone client using ./run_client.sh 23 | ``` 24 | 25 | ## OSGi client 26 | 27 | To run the client within an OSGi container such as Fuse ESB Enterprise, 28 | follow the steps given in ../README.md 29 | 30 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/EJB-Client/create-uber-jar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Helper script that create a single jar file containing all JBoss 4 | # classes needed by an external EJB client. 5 | # If additional J2EE features are used, more jar files may be 6 | # required. The jar files used here perhaps form the minimal list 7 | # of JBoss jar files required. 8 | 9 | JBOSS_HOME=~/Desktop/sandbox/JBoss/jboss-5.1.0.GA 10 | 11 | # cleanup from previous runs 12 | if [ -d tmp ] 13 | then 14 | echo "Deleting previous tmp folder" 15 | rm -r tmp 16 | fi 17 | 18 | # create tmp folder 19 | mkdir tmp 20 | cd tmp 21 | 22 | # extract all required JBoss jar files into tmp folder 23 | for i in jboss-aop-client.jar jboss-aspect-jdk50-client.jar jboss-ejb3-common-client.jar jboss-ejb3-core-client.jar jboss-ejb3-proxy-impl-client.jar jboss-ejb3-proxy-spi-client.jar jboss-ejb3-security-client.jar jboss-integration.jar jboss-javaee.jar jboss-logging-spi.jar jboss-messaging-client.jar jboss-security-spi.jar jbosssx-client.jar jnp-client.jar jboss-remoting.jar jboss-common-core.jar concurrent.jar 24 | do 25 | echo "Exrtracting $i into ./tmp" 26 | jar xvf $JBOSS_HOME/client/$i 2>&1 > /dev/null 27 | if [ $? != 0 ] 28 | then 29 | echo "Problem extracting jar $i" 30 | fi 31 | done 32 | 33 | 34 | # create uber jar 35 | echo "Creating uber jar from tmp..." 36 | jar cvf ../jboss-client-all.jar * 2>&1 > /dev/null 37 | if [ $? = 0 ] 38 | then 39 | echo "Created jboss-client-all.jar" 40 | else 41 | echo "Something went wrong." 42 | fi 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/EJB-Client/run_client.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | for i in jboss-client-all.jar ./target/classes ./target/simple-ejb-client-1.0.0.jar ~/.m2/repository/org/slf4j/slf4j-api/1.6.6/slf4j-api-1.6.6.jar ~/.m2/repository/org/slf4j/slf4j-log4j12/1.6.6/slf4j-log4j12-1.6.6.jar ~/.m2/repository/log4j/log4j/1.2.8/log4j-1.2.8.jar ../Simple-EJB/target/simple-ejb-demo-1.0.0-client.jar 5 | do 6 | CLASSPATH=$CLASSPATH:$i 7 | done 8 | 9 | echo "Using CLASSPATH=$CLASSPATH" 10 | java -cp $CLASSPATH org.apache.servicemix.demo.simpleejb.client.Client 11 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/EJB-Client/src/main/java/org/apache/servicemix/demo/simpleejb/client/Client.java: -------------------------------------------------------------------------------- 1 | package org.apache.servicemix.demo.simpleejb.client; 2 | 3 | import javax.naming.Context; 4 | import javax.naming.InitialContext; 5 | import javax.naming.NamingException; 6 | import java.util.Hashtable; 7 | 8 | import org.apache.servicemix.demo.simpleejb.SimpleGreeter; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | 13 | public class Client { 14 | 15 | final static Logger LOG = LoggerFactory.getLogger(Client.class); 16 | 17 | 18 | public static void main(String[] args) throws Exception { 19 | LOG.info("main started."); 20 | invokeStatelessBean(); 21 | } 22 | 23 | 24 | /** 25 | * Looks up a stateless bean and invokes on it 26 | * 27 | * @throws NamingException 28 | */ 29 | private static void invokeStatelessBean() throws NamingException { 30 | // Let's lookup the remote stateless calculator 31 | final SimpleGreeter bean = lookupRemoteBean(); 32 | LOG.info("Obtained a remote EJB reference for invocation."); 33 | 34 | LOG.debug("Invoking sayHi() on EJB..."); 35 | String greeting = bean.greetMe("user"); 36 | LOG.info("Result is: \"" + greeting + "\""); 37 | LOG.debug("Demo finished."); 38 | } 39 | 40 | 41 | /** 42 | * Looks up and returns the proxy to remote stateless bean 43 | * 44 | * @return 45 | * @throws NamingException 46 | */ 47 | private static SimpleGreeter lookupRemoteBean() throws NamingException { 48 | Hashtable props = new Hashtable(); 49 | props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); 50 | props.put("java.naming.provider.url", "jnp://localhost:1099"); 51 | final Context context = new InitialContext(props); 52 | 53 | String lookupName = "SimpleGreeterBean/remote"; 54 | LOG.debug("Going to lookup " + lookupName); 55 | return (SimpleGreeter) context.lookup(lookupName); 56 | } 57 | } -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/EJB-Client/src/main/java/org/apache/servicemix/demo/simpleejb/client/osgi/OSGiActivator.java: -------------------------------------------------------------------------------- 1 | package org.apache.servicemix.demo.simpleejb.client.osgi; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import org.apache.servicemix.demo.simpleejb.client.Client; 7 | import org.osgi.framework.BundleActivator; 8 | import org.osgi.framework.BundleContext; 9 | 10 | 11 | /** 12 | * @author TMIELKE 13 | * 14 | * A standard Bundle Activator 15 | */ 16 | public class OSGiActivator implements BundleActivator { 17 | 18 | private final static Logger LOG = LoggerFactory.getLogger(OSGiActivator.class); 19 | 20 | private Client client = null; 21 | 22 | 23 | /* (non-Javadoc) 24 | * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) 25 | */ 26 | public void start(BundleContext context) throws Exception { 27 | LOG.debug("OSGiActivator.start() called."); 28 | client = new Client(); 29 | client.main(null); 30 | } 31 | 32 | 33 | /* (non-Javadoc) 34 | * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) 35 | */ 36 | public void stop(BundleContext context) throws Exception { 37 | LOG.debug("OSGiActivator.stop() called."); 38 | 39 | if (null != client) { 40 | client = null; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/EJB-Client/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootCategory=INFO, out, 2 | 3 | 4 | # File1 Appender ############################################## 5 | log4j.appender.file1=org.apache.log4j.RollingFileAppender 6 | #log4j.appender.file1.Threshold=DEBUG 7 | log4j.appender.file1.File=c:/Temp/log4j_log.log 8 | log4j.appender.file1.layout=org.apache.log4j.PatternLayout 9 | log4j.appender.file1.layout.ConversionPattern=%d %-2p [%t] %c{3} - %m - %n 10 | #log4j.appender.file1.MaxFileSize=1000KB 11 | #log4j.appender.file1.MaxBackupIndex=5 12 | 13 | # File2 Appender ############################################## 14 | log4j.appender.file2=org.apache.log4j.RollingFileAppender 15 | log4j.appender.file2.File=c:/Temp/log4j_log.xml 16 | log4j.appender.file2.layout=org.apache.log4j.xml.XMLLayout 17 | 18 | 19 | #Console Appender ############################################ 20 | log4j.appender.out=org.apache.log4j.ConsoleAppender 21 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 22 | log4j.appender.out.layout.ConversionPattern=%d %p %t - %m%n 23 | 24 | 25 | log4j.logger.com.redhat.support=DEBUG 26 | 27 | # With regards to ConversionPattern, here is a description 28 | #%c = category %F = current file %m = message 29 | #%d = date %L = current line %t = thread 30 | #%p = priority %M = current method %n = newline 31 | 32 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/Simple-EJB/README.md: -------------------------------------------------------------------------------- 1 | ## Simple EJB 2 | 3 | This folder contains the stateless session bean that is to be deployed into 4 | JBoss. It has been tested with JBoss 5.1.0.GA. 5 | 6 | The EJB interface is very simple: 7 | 8 | ```java 9 | public interface SimpleGreeter { 10 | 11 | String greetMe(String name); 12 | 13 | } 14 | ``` 15 | 16 | and so is the implementation of this bean 17 | 18 | ```java 19 | @Stateless 20 | @Remote(SimpleGreeter.class ) 21 | public class SimpleGreeterBean implements SimpleGreeter { 22 | 23 | @Override 24 | public String greetMe(String name) { 25 | System.out.println("greetMe() invoked."); 26 | return "Welcome "+name + ", you have just invoked SimpleGreeterBean!"; 27 | } 28 | } 29 | ``` 30 | 31 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/Simple-EJB/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | com.apache.servicemix.demo.simpleejb 8 | simple-ejb-parent 9 | 1.0.0 10 | 11 | 12 | org.apache.servicemix.demo.simpleejb 13 | simple-ejb-demo 14 | 1.0.0 15 | ejb 16 | ServiceMix :: Demo :: OSGi to EJB :: Simple EJB 17 | Simple JBoss EJB sample for illustrating how to invoke on JBoss from OSGi 18 | 19 | 20 | UTF-8 21 | 22 | 23 | 24 | 25 | 26 | org.jboss.spec 27 | jboss-javaee-6.0 28 | 3.0.0.Final 29 | pom 30 | import 31 | 32 | 33 | 34 | 35 | 36 | 38 | 39 | org.jboss.spec.javax.annotation 40 | jboss-annotations-api_1.1_spec 41 | provided 42 | 43 | 44 | 46 | 47 | org.jboss.spec.javax.ejb 48 | jboss-ejb-api_3.1_spec 49 | provided 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.jboss.as.plugins 59 | jboss-as-maven-plugin 60 | 7.1.1.Final 61 | 62 | simple-ejb-demo-1.0.0 63 | 64 | 65 | 67 | 68 | maven-compiler-plugin 69 | 2.3.1 70 | 71 | 1.6 72 | 1.6 73 | 74 | 75 | 76 | org.apache.maven.plugins 77 | maven-ejb-plugin 78 | 2.3 79 | 80 | 3.1 81 | 82 | true 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/Simple-EJB/src/main/java/org/apache/servicemix/demo/simpleejb/SimpleGreeter.java: -------------------------------------------------------------------------------- 1 | package org.apache.servicemix.demo.simpleejb; 2 | 3 | public interface SimpleGreeter { 4 | 5 | String greetMe(String name); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/Simple-EJB/src/main/java/org/apache/servicemix/demo/simpleejb/SimpleGreeterBean.java: -------------------------------------------------------------------------------- 1 | package org.apache.servicemix.demo.simpleejb; 2 | 3 | import javax.ejb.Remote; 4 | import javax.ejb.Stateless; 5 | 6 | @Stateless 7 | @Remote(SimpleGreeter.class ) 8 | public class SimpleGreeterBean implements SimpleGreeter { 9 | 10 | 11 | @Override 12 | public String greetMe(String name) { 13 | System.out.println("greetMe() invoked."); 14 | return "Welcome "+name + ", you have just invoked SimpleGreeterBean!"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JBoss-Fuse/JBoss-Client-OSGi/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 4.0.0 5 | 6 | com.apache.servicemix.demo.simpleejb 7 | simple-ejb-parent 8 | 1.0.0 9 | ServiceMix :: Demo :: OSGi to EJB 10 | pom 11 | 12 | 13 | 14 | 15 | 16 | Simple-EJB 17 | EJB-Client 18 | 19 | 20 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiConfigAdminManagedPropertiesExample/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 4.0.0 21 | 22 | org.apache.karaf.demo 23 | config-admin-managed-properties-example 24 | 1.0-SNAPSHOT 25 | bundle 26 | Karaf Config Admin using Managed Properties Example 27 | 28 | 29 | 30 | org.apache.karaf.demo 31 | * 32 | 33 | 34 | org.apache.karaf.demo.impl 35 | 36 | 37 | 38 | 39 | org.slf4j 40 | slf4j-api 41 | 1.7.5 42 | jar 43 | compile 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-compiler-plugin 52 | 53 | 1.6 54 | 1.6 55 | true 56 | true 57 | true 58 | true 59 | 60 | 61 | 62 | 63 | org.apache.felix 64 | maven-bundle-plugin 65 | true 66 | 67 | 68 | ${osgi.export} 69 | ${osgi.import} 70 | ${osgi.bundles} 71 | ${osgi.dynamic.import} 72 | ${osgi.private} 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiConfigAdminManagedPropertiesExample/src/main/java/org/apache/karaf/demo/Ping.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 FuseSource 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.apache.karaf.demo; 17 | 18 | /** 19 | * An interface for implementing Ping services. 20 | */ 21 | public interface Ping { 22 | 23 | String ping(); 24 | } 25 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiConfigAdminManagedPropertiesExample/src/main/java/org/apache/karaf/demo/impl/PingBean.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 FuseSource 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.apache.karaf.demo.impl; 17 | 18 | import java.text.SimpleDateFormat; 19 | import java.util.Date; 20 | import java.util.Map; 21 | 22 | import org.apache.karaf.demo.Ping; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | 27 | /** 28 | * Simple bean. 29 | * Note this bean has setter methods for all of its config. 30 | * At bean instantiation time these setters will be called. 31 | * These setters will also be used on config:edit if 32 | * managed properties are set to container-managed in 33 | * blueprint. 34 | * If set to component-managed, the update() method below 35 | * will be called. 36 | */ 37 | public class PingBean implements Ping { 38 | 39 | private final Logger LOG = LoggerFactory.getLogger(PingBean.class); 40 | private String brokerUrl = ""; 41 | private String jettyPort = ""; 42 | private String pingFrequency = ""; 43 | 44 | 45 | public String ping() { 46 | LOG.info("ping() invoked."); 47 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 48 | return "Hello at " + sdf.format(new Date()); 49 | } 50 | 51 | 52 | public void setBrokerUrl(String url) { 53 | System.out.println("setBrokerUrl(" + url + ")."); 54 | LOG.info("setBrokerUrl(" + url + ")."); 55 | this.brokerUrl = url; 56 | } 57 | 58 | 59 | public void setJettyPort(String port) { 60 | System.out.println("setJettyPort(" + port + ")."); 61 | LOG.info("setJettyPort(" + port + ")."); 62 | this.jettyPort = port; 63 | } 64 | 65 | 66 | public void setPingFrequency(String freq) { 67 | System.out.println("setPingFrequency(" + freq + ")."); 68 | LOG.info("setPingFrequency(" + freq + ")."); 69 | this.pingFrequency = freq; 70 | } 71 | 72 | 73 | public void update(Map properties) { 74 | System.out.println("Received properties " + properties); 75 | LOG.info("Received properties {}", properties.toString()); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiConfigAdminManagedPropertiesExample/src/main/java/org/apache/karaf/demo/impl/PingBean2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012 FuseSource 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.apache.karaf.demo.impl; 17 | 18 | import java.text.SimpleDateFormat; 19 | import java.util.Date; 20 | import java.util.Map; 21 | 22 | import org.apache.karaf.demo.Ping; 23 | import org.slf4j.Logger; 24 | import org.slf4j.LoggerFactory; 25 | 26 | 27 | /** 28 | * Simple bean. 29 | * Note this bean does not have any setter methods. 30 | * Instead it gets its configuration via setConfig() at 31 | * instantiation time and whenever the 32 | * configuration was updated in the ConfigAdmin service. 33 | * This requires proper blueprint config to work. 34 | */ 35 | public class PingBean2 implements Ping { 36 | 37 | private final Logger LOG = LoggerFactory.getLogger(PingBean2.class); 38 | private String brokerUrl = ""; 39 | private String jettyPort = ""; 40 | private String pingFrequency = ""; 41 | 42 | public String ping() { 43 | LOG.info("ping() invoked."); 44 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 45 | return "Hello at " + sdf.format(new Date()); 46 | } 47 | 48 | 49 | public void setConfig(Map properties) { 50 | LOG.info("setConfig() called. Received properties {}", properties.toString()); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiServiceLoadingResourcesFromExternalBundle/clientBundle/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.apache.karaf.test 9 | service-resource-loading-example 10 | 0.0.1-SNAPSHOT 11 | 12 | 13 | org.apache.karaf.test.service-resource-loading-example 14 | client-bundle 15 | bundle 16 | ServiceResourceLoadingExample :: ClientBundle 17 | 0.0.1-SNAPSHOT 18 | 19 | 20 | 21 | 22 | 23 | org.apache.karaf.test.service-resource-loading-example 24 | service-bundle 25 | ${project.version} 26 | compile 27 | 28 | 29 | org.slf4j 30 | slf4j-api 31 | ${slf4j.version} 32 | compile 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.apache.maven.plugins 40 | maven-compiler-plugin 41 | 42 | 1.5 43 | 1.5 44 | UTF-8 45 | 46 | 47 | 48 | 49 | org.apache.felix 50 | maven-bundle-plugin 51 | 2.0.0 52 | true 53 | 54 | 55 | ${pom.artifactId} 56 | * 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiServiceLoadingResourcesFromExternalBundle/clientBundle/src/main/java/org/apache/karaf/demo/osgitest/client/Client.java: -------------------------------------------------------------------------------- 1 | package org.apache.karaf.demo.osgitest.client; 2 | 3 | import org.apache.karaf.demo.osgitest.OSGiTestInterface; 4 | 5 | import java.net.URL; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | /** 11 | * Simple client bundle that gets the service injected via 12 | * blueprint and calls it straight away, passing in the url 13 | * to an xml file that resides locally in this bundle. 14 | */ 15 | public class Client { 16 | 17 | private Logger LOG = LoggerFactory.getLogger(Client.class); 18 | private OSGiTestInterface service = null; 19 | 20 | public void doIt() { 21 | LOG.info("Client.doIt() invoked."); 22 | URL url = this.getClass().getClassLoader().getResource("OSGI-INF/blueprint/blueprint.xml"); 23 | LOG.info("url is " + url); 24 | 25 | // Invoke the service, pass in the resource url 26 | service.invokeService(url.toString()); 27 | LOG.debug("service() called succesfully."); 28 | LOG.debug("Done with doIt()"); 29 | } 30 | 31 | 32 | /** 33 | * Injects the OSGi service proxy and directly invokes the service 34 | * (invocation for testing purposes). 35 | * @param service 36 | */ 37 | public void setService(OSGiTestInterface service) { 38 | LOG.debug("setService() invoked."); 39 | this.service = service; 40 | doIt(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiServiceLoadingResourcesFromExternalBundle/clientBundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiServiceLoadingResourcesFromExternalBundle/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | org.apache.karaf.test 7 | service-resource-loading-example 8 | pom 9 | ServiceResourceLoadingExample 10 | 0.0.1-SNAPSHOT 11 | 12 | 13 | 14 | 15 | 1.7.5 16 | 17 | 18 | 19 | serviceBundle 20 | clientBundle 21 | 22 | 23 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiServiceLoadingResourcesFromExternalBundle/serviceBundle/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/main/java/,src/main/resources/,src/test/java,src/test/resources 2 | output.. = target/classes/,target/test-classes 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | target/classes/ 6 | src.includes = src/main/java/,\ 7 | src/main/resources/,\ 8 | src/test/java/,\ 9 | src/test/resources/ 10 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiServiceLoadingResourcesFromExternalBundle/serviceBundle/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | org.apache.karaf.test 9 | service-resource-loading-example 10 | 0.0.1-SNAPSHOT 11 | 12 | 13 | org.apache.karaf.test.service-resource-loading-example 14 | service-bundle 15 | bundle 16 | ServiceResourceLoadingExample :: ServiceBundle 17 | 0.0.1-SNAPSHOT 18 | 19 | 20 | 21 | 22 | 23 | org.slf4j 24 | slf4j-api 25 | ${slf4j.version} 26 | compile 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.apache.maven.plugins 34 | maven-compiler-plugin 35 | 36 | 1.5 37 | 1.5 38 | UTF-8 39 | 40 | 41 | 42 | 43 | org.apache.felix 44 | maven-bundle-plugin 45 | 2.0.0 46 | true 47 | 48 | 49 | ${pom.artifactId} 50 | * 51 | org.apache.karaf.demo.osgitest 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiServiceLoadingResourcesFromExternalBundle/serviceBundle/src/main/java/org/apache/karaf/demo/osgitest/OSGiTestInterface.java: -------------------------------------------------------------------------------- 1 | package org.apache.karaf.demo.osgitest; 2 | 3 | /** 4 | * This is the service interface. 5 | */ 6 | public interface OSGiTestInterface { 7 | 8 | /** 9 | * Simple test method to show the application got invoked. 10 | */ 11 | public void invokeService(String resourceName); 12 | } 13 | 14 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiServiceLoadingResourcesFromExternalBundle/serviceBundle/src/main/java/org/apache/karaf/demo/osgitest/internal/OSGiTestImpl.java: -------------------------------------------------------------------------------- 1 | package org.apache.karaf.demo.osgitest.internal; 2 | 3 | import org.apache.karaf.demo.osgitest.OSGiTestInterface; 4 | 5 | import java.io.BufferedReader; 6 | import java.io.InputStream; 7 | import java.io.InputStreamReader; 8 | import java.net.URL; 9 | 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | 13 | 14 | /** 15 | * Simple bundle that gets exported in the OSGi service registry 16 | * using the interface OSGiTestInterface 17 | */ 18 | public class OSGiTestImpl implements OSGiTestInterface { 19 | 20 | private final Logger LOG = LoggerFactory.getLogger(OSGiTestImpl.class); 21 | private static int counter; 22 | 23 | 24 | /** 25 | * Implementation of service interface. 26 | * @param resourceName the name of the resource in url format 27 | * bundle:[id].[rev]/[path] 28 | */ 29 | public void invokeService(String resourceName) { 30 | LOG.info("OSGiTestImpl.invokeService(" + resourceName + ") called."); 31 | 32 | try { 33 | // convert String to URL 34 | URL url = new URL(resourceName); 35 | 36 | // open url and read the content. Note the resource that gets read 37 | // here resides in a different bundle 38 | InputStream stream = url.openStream(); 39 | BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); 40 | String line = null; 41 | LOG.debug("Going to read external resource."); 42 | do { 43 | line = reader.readLine(); 44 | LOG.info(line); 45 | } while (line != null); 46 | } catch (Exception ex) { 47 | LOG.error(ex.getMessage()); 48 | } 49 | LOG.debug("Done with invokeService()"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /JBoss-Fuse/OSGiServiceLoadingResourcesFromExternalBundle/serviceBundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml: -------------------------------------------------------------------------------- 1 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /JBoss-Fuse/README.md: -------------------------------------------------------------------------------- 1 | #Overview 2 | 3 | This directory contains some JBoss-Fuse / Karaf / OSGi specific demos. 4 | 5 | ## JBoss-Client-OSGi 6 | OSGi bundle that invokes a J2EE bean deployed in JBoss EAP. 7 | 8 | ## OSGiConfigAdminManagedPropertiesExample 9 | Demo that shows how to use the OSGi Configuration Admin Service and managed configuration properties. 10 | 11 | ## OSGiServiceLoadingResourcesFromExternalBundle 12 | This demo consists of two OSGi bundles. 13 | serviceBundle exposes a simple OSGi service which takes a resource string as an argument. 14 | clientBundle invokes the service and passes in a resource url that points to a resource within 15 | the clientBundle jar file. 16 | The service that is invoked is able to load the resource from the other bundle. 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /JBoss-Fuse/jaas-login-module-example-6.0/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 22 | 4.0.0 23 | 24 | org.fusesource.fabric.jaas.test 25 | jaas-login-module-example 26 | 6.0 27 | bundle 28 | 29 | Example JAAS Login Module definition that overrides the defaults 30 | Example JAAS Login Module that overrides the default ZookeeperLoginModule and uses LDAP as a backup login module 31 | 32 | 33 | 34 | 35 | 36 | org.apache.felix 37 | maven-bundle-plugin 38 | 2.3.7 39 | true 40 | 41 | 42 | ${project.artifactId} 43 | ${project.version} 44 | org.apache.karaf.jaas.modules 45 | 46 | 47 | 48 | *,org.apache.karaf.jaas.config;version="2.3.0.redhat-60024" 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /JBoss-Fuse/jaas-login-module-example-6.0/src/main/resources/OSGI-INF/blueprint/jaas.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | path = /fabric/authentication/users 31 | encryption.name = ${encryption.name} 32 | encryption.enabled = ${encryption.enabled} 33 | encryption.prefix = ${encryption.prefix} 34 | encryption.suffix = ${encryption.suffix} 35 | encryption.algorithm = ${encryption.algorithm} 36 | encryption.encoding = ${encryption.encoding} 37 | 38 | 39 | initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory 40 | connection.url=ldap://localhost:10389 41 | connection.username=uid=admin,ou=system 42 | connection.password=secret 43 | connection.protocol= 44 | authentication=simple 45 | user.base.dn=ou=User,ou=ActiveMQ,ou=system 46 | user.filter=(uid=%u) 47 | user.search.subtree=true 48 | role.base.dn=ou=Group,ou=ActiveMQ,ou=system 49 | role.name.attribute=cn 50 | role.filter=(member=uid=%u,ou=User,ou=ActiveMQ,ou=system) 51 | role.search.subtree=true 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /JBoss-Fuse/jaas-login-module-example-6.1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 22 | 4.0.0 23 | 24 | io.fabric8.jaas.test 25 | jaas-login-module-example 26 | 6.1 27 | bundle 28 | 29 | Example JAAS Login Module definition that overrides the defaults 30 | Example JAAS Login Module that overrides the default ZookeeperLoginModule and uses LDAP as a backup login module 31 | 32 | 33 | 34 | 35 | 36 | org.apache.felix 37 | maven-bundle-plugin 38 | 2.3.7 39 | true 40 | 41 | 42 | ${project.artifactId} 43 | ${project.version} 44 | org.apache.karaf.jaas.modules 45 | 46 | 47 | 48 | *,org.apache.karaf.jaas.config;version="2.3.0.redhat-60024" 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /JBoss-Fuse/jaas-login-module-example-6.1/src/main/resources/OSGI-INF/blueprint/jaas.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | path = /fabric/authentication/users 16 | debug=true 17 | encryption.name= 18 | encryption.enabled=true 19 | encryption.prefix={CRYPT} 20 | encryption.suffix={CRYPT} 21 | encryption.algorithm=MD5 22 | encryption.encoding=hexadecimal 23 | 24 | 25 | 26 | 27 | initialContextFactory=com.sun.jndi.ldap.LdapCtxFactory 28 | connection.url=ldap://localhost:10389 29 | connection.username=uid=admin,ou=system 30 | connection.password=secret 31 | connection.protocol= 32 | authentication=simple 33 | user.base.dn=ou=User,ou=ActiveMQ,ou=system 34 | user.filter=(uid=%u) 35 | user.search.subtree=true 36 | role.base.dn=ou=Group,ou=ActiveMQ,ou=system 37 | role.name.attribute=cn 38 | role.filter=(member=uid=%u,ou=User,ou=ActiveMQ,ou=system) 39 | role.search.subtree=true 40 | debug=true 41 | 42 | 43 | ssl=false 44 | ssl.truststore=truststore 45 | ssl.protocol=SSL 46 | ssl.algorithm=PKIX 47 | 51 | 52 | 53 | 56 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | fuse-demos 2 | ========== 3 | 4 | This repository contains a collection of demos for FuseSource products. 5 | --------------------------------------------------------------------------------