├── .gitignore ├── src ├── test │ ├── resources │ │ ├── org │ │ │ └── apache │ │ │ │ └── servicemix │ │ │ │ ├── components │ │ │ │ └── util │ │ │ │ │ ├── fixedlength.txt │ │ │ │ │ ├── csv_simplesample.csv │ │ │ │ │ ├── fixedlength_morecomplex.txt │ │ │ │ │ └── encoding.xml │ │ │ │ ├── expression │ │ │ │ └── expression-editor.xml │ │ │ │ └── jbi │ │ │ │ └── jaxp │ │ │ │ └── test.xml │ │ ├── log4j-tests.properties │ │ └── log4j.properties │ └── java │ │ └── org │ │ └── apache │ │ └── servicemix │ │ ├── expression │ │ ├── ExpressionTestSupport.java │ │ ├── ExpressionEditorTest.java │ │ ├── JAXPXPathXStreamExpressionTest.java │ │ ├── JAXPXPathExpressionTest.java │ │ └── XPathExpressionTest.java │ │ ├── locks │ │ └── impl │ │ │ └── SimpleLockTest.java │ │ ├── store │ │ ├── memory │ │ │ ├── MemoryStoreFactoryTest.java │ │ │ └── ConcurrentTimeoutMemoryStoreTest.java │ │ ├── jdbc │ │ │ └── JdbcStoreTest.java │ │ └── krati │ │ │ └── KratiStoreTest.java │ │ ├── converter │ │ └── ConvertersTest.java │ │ ├── executors │ │ └── impl │ │ │ ├── ExecutorFactoryImplTest.java │ │ │ └── LogThrowableInExecutorTest.java │ │ ├── jbi │ │ ├── transformer │ │ │ └── CopyTransformerTest.java │ │ └── jaxp │ │ │ ├── WsRfRpTest.java │ │ │ └── FragmentStreamReaderTest.java │ │ └── tck │ │ └── mock │ │ └── MockExchangeFactoryTest.java └── main │ ├── resources │ ├── OSGI-INF │ │ └── bundle.info │ └── META-INF │ │ └── services │ │ └── org │ │ └── apache │ │ └── servicemix │ │ └── jdbc │ │ ├── sap_db │ │ ├── axion_jdbc_driver │ │ ├── sqlserver │ │ ├── i-net_sprinta_2000 │ │ ├── mysql-ab_jdbc_driver │ │ ├── oracle_jdbc_driver │ │ ├── hsql_database_engine_driver │ │ ├── jconnect__tm__for_jdbc__tm_ │ │ ├── postgresql_native_driver │ │ ├── apache_derby_embedded_jdbc_driver │ │ ├── ibm_db2_jdbc_universal_driver_architecture │ │ ├── jtds_type_4_jdbc_driver_for_ms_sql_server_and_sybase │ │ └── ibm_informix_jdbc_driver_for_ibm_informix_dynamic_server │ └── java │ └── org │ └── apache │ └── servicemix │ ├── expression │ ├── package.html │ ├── ExpressionEditor.java │ ├── ConstantExpression.java │ ├── JaxenStringXPathExpression.java │ ├── Expression.java │ ├── JAXPNodeSetXPathExpression.java │ ├── JAXPStringXPathExpression.java │ ├── JAXPBooleanXPathExpression.java │ ├── ExpressionHelper.java │ ├── XMLBeansStringXPathExpression.java │ ├── PropertyExpression.java │ ├── XMLBeansXPathExpression.java │ └── MessageVariableResolver.java │ ├── jbi │ ├── jaxp │ │ ├── package.html │ │ ├── ExtendedNamespaceContext.java │ │ ├── JavaSource.java │ │ ├── DOMStreamWriter.java │ │ ├── SourceMarshaler.java │ │ ├── BytesSource.java │ │ ├── QNameHelper.java │ │ ├── ResourceSource.java │ │ └── StringSource.java │ ├── api │ │ ├── Container.java │ │ ├── EndpointFilter.java │ │ ├── ClientFactory.java │ │ ├── EndpointResolver.java │ │ ├── Message.java │ │ └── Destination.java │ ├── listener │ │ └── MessageExchangeListener.java │ ├── exception │ │ ├── NoFaultAvailableException.java │ │ ├── NoInMessageAvailableException.java │ │ ├── NoOutMessageAvailableException.java │ │ └── FaultException.java │ ├── transformer │ │ ├── PropertyAddTransformer.java │ │ └── MessageTransformer.java │ └── marshaler │ │ └── PojoMarshaler.java │ ├── timers │ ├── TimerListener.java │ ├── Timer.java │ └── TimerManager.java │ ├── executors │ ├── package.html │ ├── impl │ │ ├── package.html │ │ ├── ManagedExecutorMBean.java │ │ └── WrappedRejectedExecutionHandler.java │ ├── ExecutorAwareRunnable.java │ ├── Executor.java │ └── WorkManagerWrapper.java │ ├── locks │ ├── LockManager.java │ └── impl │ │ └── SimpleLockManager.java │ ├── jdbc │ ├── adapter │ │ ├── AxionJDBCAdapter.java │ │ ├── InformixJDBCAdapter.java │ │ ├── HsqldbJDBCAdapter.java │ │ ├── MaxDBJDBCAdapter.java │ │ ├── DB2JDBCAdapter.java │ │ ├── BlobJDBCAdapter.java │ │ ├── ImageBasedJDBCAdaptor.java │ │ ├── PostgresqlJDBCAdapter.java │ │ ├── BytesJDBCAdapter.java │ │ ├── OracleJDBCAdapter.java │ │ └── StreamJDBCAdapter.java │ └── JDBCAdapter.java │ ├── components │ └── util │ │ ├── ColumnExtractor.java │ │ ├── XmlEscapingConverter.java │ │ ├── TextStripConverter.java │ │ ├── StreamDataSource.java │ │ ├── NoConversion.java │ │ ├── ContentConverter.java │ │ ├── MarshalerSupport.java │ │ ├── NumberConverter.java │ │ └── FileExtensionPropertyExpression.java │ ├── store │ ├── StoreFactory.java │ ├── base │ │ ├── BaseStoreFactory.java │ │ └── BaseStore.java │ ├── StoreListener.java │ ├── Entry.java │ ├── redis │ │ └── RedisStoreFactory.java │ └── memory │ │ ├── MemoryStore.java │ │ └── MemoryStoreFactory.java │ ├── util │ └── jaf │ │ ├── ByteArrayDataSource.java │ │ └── StreamDataSource.java │ └── tck │ └── mock │ └── MockNormalizedMessage.java └── NOTICE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | derby.log 3 | .classpath 4 | .project 5 | .settings 6 | *.i?? 7 | .idea -------------------------------------------------------------------------------- /src/test/resources/org/apache/servicemix/components/util/fixedlength.txt: -------------------------------------------------------------------------------- 1 | AABBBCCCCC 2 | CCBBBAAAAA 3 | AABBBCCCCC 4 | -------------------------------------------------------------------------------- /src/test/resources/org/apache/servicemix/components/util/csv_simplesample.csv: -------------------------------------------------------------------------------- 1 | AA;B;CCCC 2 | C;BBB;AAAAA 3 | AA;B;C 4 | -------------------------------------------------------------------------------- /src/test/resources/org/apache/servicemix/components/util/fixedlength_morecomplex.txt: -------------------------------------------------------------------------------- 1 | 01B CCCCC20070215 2 | 02BB AAAAA 3 | 03BBBCCCCC20070216 4 | -------------------------------------------------------------------------------- /src/test/resources/org/apache/servicemix/components/util/encoding.xml: -------------------------------------------------------------------------------- 1 | 2 | l'élève est à l'école 3 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | ========================================================================= 2 | == NOTICE file for use with the Apache License, Version 2.0, == 3 | == in this case for the Apache ServiceMix distribution. == 4 | ========================================================================= 5 | 6 | This product contains software developed by 7 | The Apache Software Foundation (http://www.apache.org/). 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/main/resources/OSGI-INF/bundle.info: -------------------------------------------------------------------------------- 1 | \u001B[1mSYNOPSIS\u001B[0m 2 | ${project.description} 3 | 4 | Original Maven URL: 5 | \u001B[33mmvn:${project.groupId}/${project.artifactId}/${project.version}\u001B[0m 6 | 7 | \u001B[1mDESCRIPTION\u001B[0m 8 | Apache ServiceMix Utils provides a set of utility classes used in a wide ServiceMix modules. 9 | 10 | You can find the different store implementations supported by ServiceMix, such as: 11 | * Hazelcast 12 | * JDBC 13 | * Memory 14 | * MongoDB 15 | * Redis 16 | 17 | You can also find some marshalers and converters used in the components. 18 | 19 | \u001B[1mSEE ALSO\u001B[0m 20 | \u001B[36mhttp://servicemix.apache.org/\u001B[0m 21 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sap_db: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.MaxDBJDBCAdapter 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/axion_jdbc_driver: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.AxionJDBCAdapter 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/sqlserver: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.ImageBasedJDBCAdaptor 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/i-net_sprinta_2000: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.ImageBasedJDBCAdaptor 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/mysql-ab_jdbc_driver: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.DefaultJDBCAdapter 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/oracle_jdbc_driver: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.OracleJDBCAdapter 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/hsql_database_engine_driver: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.HsqldbJDBCAdapter 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jconnect__tm__for_jdbc__tm_: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.ImageBasedJDBCAdaptor 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/postgresql_native_driver: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.PostgresqlJDBCAdapter 22 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/package.html: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 24 | A pluggable expression library. 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/apache_derby_embedded_jdbc_driver: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.DefaultJDBCAdapter 22 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/jaxp/package.html: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 24 | JAXP and XML related utility classes 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_db2_jdbc_universal_driver_architecture: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.DB2JDBCAdapter 22 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/timers/TimerListener.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.apache.servicemix.timers; 18 | 19 | public interface TimerListener { 20 | 21 | void timerExpired(Timer timer); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/jtds_type_4_jdbc_driver_for_ms_sql_server_and_sybase: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.ImageBasedJDBCAdaptor 22 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/services/org/apache/servicemix/jdbc/ibm_informix_jdbc_driver_for_ibm_informix_dynamic_server: -------------------------------------------------------------------------------- 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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | class=org.apache.servicemix.jdbc.adapter.InformixJDBCAdapter 22 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/executors/package.html: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 24 | API for configurable thread pools. 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/timers/Timer.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.apache.servicemix.timers; 18 | 19 | public interface Timer { 20 | 21 | boolean cancel(); 22 | 23 | TimerListener getTimerListener(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/executors/impl/package.html: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 24 | Implementations of configurable thread pools. 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/locks/LockManager.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.apache.servicemix.locks; 18 | 19 | import java.util.concurrent.locks.Lock; 20 | 21 | @Deprecated 22 | public interface LockManager { 23 | 24 | Lock getLock(String id); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/AxionJDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | 20 | 21 | /** 22 | * Axion specific Adapter. 23 | * 24 | * @org.apache.xbean.XBean element="axionJDBCAdapter" 25 | * @version $Revision: 1.4 $ 26 | */ 27 | public class AxionJDBCAdapter extends StreamJDBCAdapter { 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/components/util/ColumnExtractor.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.apache.servicemix.components.util; 18 | 19 | /** 20 | * Interface for extracting column contents from a text line 21 | * @author Mayrbaeurl 22 | * @since 3.2 23 | */ 24 | public interface ColumnExtractor { 25 | 26 | String[] extractColumns(String lineText); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/timers/TimerManager.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.apache.servicemix.timers; 18 | 19 | import java.util.Date; 20 | 21 | public interface TimerManager { 22 | 23 | Timer schedule(TimerListener listener, long delay); 24 | 25 | Timer schedule(TimerListener listener, Date date); 26 | 27 | void start(); 28 | 29 | void stop(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/InformixJDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | 20 | /** 21 | * JDBC Adapter for Informix database. 22 | * Informix database restricts length of composite keys. 23 | * 24 | * @org.apache.xbean.XBean element="informixJDBCAdapter" 25 | */ 26 | public class InformixJDBCAdapter extends BlobJDBCAdapter { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/ExpressionEditor.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.apache.servicemix.expression; 18 | 19 | import java.beans.PropertyEditorSupport; 20 | 21 | public class ExpressionEditor extends PropertyEditorSupport { 22 | 23 | @Override 24 | public void setAsText(String text) throws IllegalArgumentException { 25 | setValue(new ConstantExpression(text)); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/api/Container.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.apache.servicemix.jbi.api; 18 | 19 | /** 20 | * Represents the ServiceMix JBI container 21 | */ 22 | public interface Container { 23 | 24 | /** 25 | * Get a {@link ClientFactory} for building a client to access this container 26 | * 27 | * @return the factory 28 | */ 29 | ClientFactory getClientFactory(); 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/expression/ExpressionTestSupport.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.apache.servicemix.expression; 18 | 19 | public class ExpressionTestSupport { 20 | 21 | private Expression expression; 22 | 23 | public Expression getExpression() { 24 | return expression; 25 | } 26 | 27 | public void setExpression(Expression expression) { 28 | this.expression = expression; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/resources/org/apache/servicemix/expression/expression-editor.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | test 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/HsqldbJDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | import org.apache.servicemix.jdbc.Statements; 20 | 21 | /** 22 | * 23 | * @version $Revision: 1.2 $ 24 | */ 25 | public class HsqldbJDBCAdapter extends BytesJDBCAdapter { 26 | 27 | public void setStatements(Statements statements) { 28 | statements.setBinaryDataType("OTHER"); 29 | super.setStatements(statements); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/MaxDBJDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | import org.apache.servicemix.jdbc.Statements; 20 | 21 | /** 22 | * JDBC Adapter for the MaxDB database. 23 | */ 24 | public class MaxDBJDBCAdapter extends DefaultJDBCAdapter { 25 | 26 | public void setStatements(Statements statements) { 27 | statements.setBinaryDataType("LONG BYTE"); 28 | statements.setIdDataType("VARCHAR(250) ASCII"); 29 | super.setStatements(statements); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/locks/impl/SimpleLockTest.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.apache.servicemix.locks.impl; 18 | 19 | import java.util.concurrent.locks.Lock; 20 | 21 | import junit.framework.TestCase; 22 | 23 | public class SimpleLockTest extends TestCase { 24 | 25 | public void testSimple() { 26 | @SuppressWarnings("deprecation") 27 | Lock l = new SimpleLock(); 28 | 29 | assertTrue(l.tryLock()); 30 | assertFalse(l.tryLock()); 31 | l.unlock(); 32 | l.lock(); 33 | l.unlock(); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/jaxp/ExtendedNamespaceContext.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.apache.servicemix.jbi.jaxp; 18 | 19 | import java.util.Iterator; 20 | 21 | import javax.xml.namespace.NamespaceContext; 22 | 23 | public interface ExtendedNamespaceContext extends NamespaceContext { 24 | 25 | /** 26 | * Returns an {@link Iterator} of all namespace prefixes in scope within 27 | * this context, including those inherited from ancestor contexts. 28 | * 29 | * @return An {@link Iterator} of prefix {@link String}s. 30 | */ 31 | Iterator getPrefixes(); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/jaxp/JavaSource.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.apache.servicemix.jbi.jaxp; 18 | 19 | import javax.xml.transform.Source; 20 | 21 | /** 22 | * Represents an API to a JAXP {@link Source} which is capable of holding on to a POJO 23 | * 24 | * @version $Revision: 564374 $ 25 | */ 26 | public interface JavaSource extends Source { 27 | 28 | /** 29 | * Returns the POJO equivalent of the Source 30 | */ 31 | Object getObject(); 32 | 33 | /** 34 | * Sets the POJO equivalent of the Source 35 | */ 36 | void setObject(Object object); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/store/StoreFactory.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.apache.servicemix.store; 18 | 19 | import java.io.IOException; 20 | 21 | public interface StoreFactory { 22 | 23 | /** 24 | * Opens a {@link Store} with the specified name. 25 | * @param name 26 | * @return 27 | * @throws IOException 28 | */ 29 | Store open(String name) throws IOException; 30 | 31 | /** 32 | * Closes a {@link Store} with the specified name, 33 | * @param store 34 | * @throws IOException 35 | */ 36 | void close(Store store) throws IOException; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/jaxp/DOMStreamWriter.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.apache.servicemix.jbi.jaxp; 18 | 19 | /* 20 | * This implementation comes from the XFire project 21 | * https://svn.codehaus.org/xfire/trunk/xfire/xfire-core/src/main/org/codehaus/xfire/util/stax/ 22 | */ 23 | 24 | import javax.xml.stream.XMLStreamException; 25 | import javax.xml.stream.XMLStreamWriter; 26 | 27 | public abstract class DOMStreamWriter implements XMLStreamWriter { 28 | 29 | public void close() throws XMLStreamException { 30 | } 31 | 32 | public void flush() throws XMLStreamException { 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/components/util/XmlEscapingConverter.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.apache.servicemix.components.util; 18 | 19 | /** 20 | * 21 | * @author Andrew Skiba 22 | */ 23 | public class XmlEscapingConverter implements ContentConverter { 24 | 25 | public String convertToXml(String contents) { 26 | return contents.replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&"); 27 | } 28 | 29 | public String convertToFlatFileContent(String contents) { 30 | return contents.replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/DB2JDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | import java.sql.Blob; 20 | import java.sql.ResultSet; 21 | import java.sql.SQLException; 22 | 23 | /** 24 | * 25 | * @org.apache.xbean.XBean element="db2JDBCAdapter" 26 | * 27 | * @version $Revision: 1.2 $ 28 | */ 29 | public class DB2JDBCAdapter extends DefaultJDBCAdapter { 30 | 31 | protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException { 32 | // Get as a BLOB 33 | Blob aBlob = rs.getBlob(index); 34 | return aBlob.getBytes(1, (int) aBlob.length()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/listener/MessageExchangeListener.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.apache.servicemix.jbi.listener; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | 22 | /** 23 | * Interface to be notified when a {@link MessagingException} is received 24 | * 25 | * @version $Revision: 564607 $ 26 | */ 27 | public interface MessageExchangeListener { 28 | 29 | /** 30 | * MessageExchange passed directly to the listener 31 | * 32 | * @param exchange 33 | * @throws MessagingException 34 | */ 35 | void onMessageExchange(MessageExchange exchange) throws MessagingException; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/api/EndpointFilter.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.apache.servicemix.jbi.api; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.servicedesc.ServiceEndpoint; 21 | 22 | /** 23 | * Represents a filter used to exclude endpoints before choosing which endpoint to use 24 | * 25 | * @version $Revision: 564607 $ 26 | */ 27 | public interface EndpointFilter { 28 | 29 | /** 30 | * Performs the filter on the endpoint returning true if the endpoint is suitable, based on some 31 | * capabilities evaluation or false if the endpoint should be ignored. 32 | */ 33 | boolean evaluate(ServiceEndpoint endpoint, MessageExchange exchange); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/ConstantExpression.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | 23 | /** 24 | * Represents a constant expression 25 | * 26 | * @version $Revision: 426415 $ 27 | */ 28 | public class ConstantExpression implements Expression { 29 | private Object value; 30 | 31 | public ConstantExpression(Object value) { 32 | this.value = value; 33 | } 34 | 35 | public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException { 36 | return value; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/BlobJDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | 20 | 21 | /** 22 | * This JDBCAdapter inserts and extracts BLOB data using the 23 | * getBlob()/setBlob() operations. This is a little more involved 24 | * since to insert a blob you have to: 25 | * 26 | * 1: insert empty blob. 27 | * 2: select the blob 28 | * 3: finally update the blob with data value. 29 | * 30 | * The databases/JDBC drivers that use this adapter are: 31 | * 34 | * 35 | * @org.apache.xbean.XBean element="blobJDBCAdapter" 36 | * 37 | * @version $Revision: 1.2 $ 38 | */ 39 | public class BlobJDBCAdapter extends DefaultJDBCAdapter { 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/ImageBasedJDBCAdaptor.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.apache.servicemix.jdbc.adapter; 18 | 19 | import org.apache.servicemix.jdbc.Statements; 20 | 21 | /** 22 | * Provides JDBCAdapter since that uses 23 | * IMAGE datatype to hold binary data. 24 | * 25 | * The databases/JDBC drivers that use this adapter are: 26 | * 30 | * 31 | * @org.apache.xbean.XBean element="imageBasedJDBCAdaptor" 32 | */ 33 | public class ImageBasedJDBCAdaptor extends DefaultJDBCAdapter { 34 | 35 | public void setStatements(Statements statements) { 36 | statements.setBinaryDataType("IMAGE"); 37 | super.setStatements(statements); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/store/base/BaseStoreFactory.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.apache.servicemix.store.base; 18 | 19 | import org.apache.servicemix.store.StoreFactory; 20 | import org.apache.servicemix.store.StoreListener; 21 | 22 | import java.util.LinkedHashSet; 23 | import java.util.Set; 24 | 25 | /** 26 | * @author: iocanel 27 | */ 28 | public abstract class BaseStoreFactory implements StoreFactory { 29 | 30 | protected Set storeListeners = new LinkedHashSet(); 31 | 32 | public Set getStoreListeners() { 33 | return storeListeners; 34 | } 35 | 36 | public void setStoreListeners(Set storeListeners) { 37 | this.storeListeners = storeListeners; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/components/util/TextStripConverter.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.apache.servicemix.components.util; 18 | 19 | /** 20 | * Column converter for SimpleFlatFileMarshaler that strips off leading and 21 | * trailing whitespaces from flat file columns 22 | * 23 | * @author Mayrbaeurl 24 | * @since 3.2 25 | */ 26 | public class TextStripConverter implements ContentConverter { 27 | 28 | // Implementation methods 29 | // ------------------------------------------------------------------------- 30 | public String convertToXml(String contents) { 31 | return StringUtils.strip(contents, null); 32 | } 33 | 34 | public String convertToFlatFileContent(String contents) { 35 | return contents; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/JaxenStringXPathExpression.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.apache.servicemix.expression; 18 | 19 | import org.jaxen.JaxenException; 20 | 21 | /** 22 | * An {@link Expression} which evaluates an XPath expression using Jaxen and 23 | * returns the String value. 24 | * 25 | * @version $Revision: 450003 $ 26 | */ 27 | public class JaxenStringXPathExpression extends JaxenXPathExpression { 28 | 29 | public JaxenStringXPathExpression() { 30 | } 31 | 32 | public JaxenStringXPathExpression(String xpath) throws Exception { 33 | super(xpath); 34 | } 35 | 36 | protected Object evaluateXPath(Object object) throws JaxenException { 37 | return getXpathObject().stringValueOf(object); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/executors/ExecutorAwareRunnable.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.apache.servicemix.executors; 18 | 19 | /** 20 | * An enhanced runnable interface that can be implemented 21 | * by tasks submitted to the Executor. 22 | */ 23 | public interface ExecutorAwareRunnable extends Runnable { 24 | 25 | /** 26 | * This method can be used by the executor to have a hint whether the internal thread 27 | * pool can be bypassed for the execution of this runnable. 28 | * If the Executor supports such things and the method returns true, 29 | * this task will be executed in the caller thread. 30 | * 31 | * @return true if the executor thread pool can be bypassed for this task 32 | */ 33 | boolean shouldRunSynchronously(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/Expression.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | 23 | /** 24 | * An expression strategy for extracting or calculating some value from a message. 25 | * 26 | * @version $Revision: 564374 $ 27 | */ 28 | public interface Expression { 29 | 30 | /** 31 | * Evaluates the expression on the given exchange and message. 32 | * 33 | * @param exchange the message exchange 34 | * @param message the message, typically an inbound message 35 | * @return the value of the expression 36 | */ 37 | Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException; 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/store/memory/MemoryStoreFactoryTest.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.apache.servicemix.store.memory; 18 | 19 | import junit.framework.TestCase; 20 | 21 | /** 22 | * Test case for {@link MemoryStoreFactory} 23 | */ 24 | public class MemoryStoreFactoryTest extends TestCase { 25 | 26 | private MemoryStoreFactory factory; 27 | 28 | @Override 29 | protected void setUp() throws Exception { 30 | super.setUp(); 31 | factory = new MemoryStoreFactory(); 32 | } 33 | 34 | public void testOpen() throws Exception { 35 | assertTrue(factory.open("store1") instanceof MemoryStore); 36 | factory.setTimeout(500); 37 | assertTrue(factory.open("store1") instanceof MemoryStore); 38 | assertTrue(factory.open("store2") instanceof TimeoutMemoryStore); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/components/util/StreamDataSource.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.apache.servicemix.components.util; 18 | 19 | import java.io.InputStream; 20 | 21 | /** 22 | * Stream DataSource for Mail and message attachments . 23 | * 24 | * @author Guillaume Nodet 25 | * @since 3.0 26 | * @deprecated use org.apache.servicemix.util.jaf.StreamDataSource instead 27 | */ 28 | public class StreamDataSource extends org.apache.servicemix.util.jaf.StreamDataSource { 29 | 30 | public StreamDataSource(InputStream in) { 31 | super(in); 32 | } 33 | 34 | public StreamDataSource(InputStream in, String contentType) { 35 | super(in, contentType); 36 | } 37 | 38 | public StreamDataSource(InputStream in, String contentType, String name) { 39 | super(in, contentType, name); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/locks/impl/SimpleLockManager.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.apache.servicemix.locks.impl; 18 | 19 | import java.util.concurrent.ConcurrentHashMap; 20 | import java.util.concurrent.ConcurrentMap; 21 | import java.util.concurrent.locks.Lock; 22 | 23 | import org.apache.servicemix.locks.LockManager; 24 | 25 | @Deprecated 26 | public class SimpleLockManager implements LockManager { 27 | 28 | private ConcurrentMap locks = new ConcurrentHashMap(); 29 | 30 | public Lock getLock(String id) { 31 | Lock lock = locks.get(id); 32 | if (lock == null) { 33 | lock = new SimpleLock(); 34 | Lock oldLock = locks.putIfAbsent(id, lock); 35 | if (oldLock != null) { 36 | lock = oldLock; 37 | } 38 | } 39 | return lock; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/components/util/NoConversion.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.apache.servicemix.components.util; 18 | 19 | /** 20 | * Column contents converter for SimpleFlatFileMarshaler that does 21 | * no conversion at all 22 | * @author Juergen Mayrbaeurl 23 | * @since 3.2 24 | */ 25 | public class NoConversion implements ContentConverter { 26 | 27 | /** 28 | * No conversion of the column contents 29 | * @param contents Column contents 30 | * @return parameter contents 31 | */ 32 | public final String convertToXml(String contents) { 33 | return contents; 34 | } 35 | 36 | /** 37 | * No conversion of the column contents 38 | * @param contents Column contents 39 | * @return parameter contents 40 | */ 41 | public String convertToFlatFileContent(String contents) { 42 | return contents; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/store/StoreListener.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.apache.servicemix.store; 18 | 19 | /** 20 | * A listener interface for {@link Store} implementations. 21 | * @author: iocanel 22 | */ 23 | public interface StoreListener { 24 | 25 | /** 26 | * Method that is called each time an item is added. 27 | * @param id 28 | * @param data 29 | */ 30 | public void onAdd(String id, Object data); 31 | 32 | /** 33 | * Method that is called each time an item is removed. 34 | * @param id 35 | * @param data 36 | */ 37 | public void onRemove(String id, Object data); 38 | 39 | /** 40 | * Method that is called each time an item is evicted. 41 | * Please note that not all {@link Store}s support eviction. 42 | * @param id 43 | * @param data 44 | */ 45 | public void onEvict(String id, Object data); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/components/util/ContentConverter.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.apache.servicemix.components.util; 18 | 19 | /** 20 | * Interface for the conversion of columns content to XML and vice versa 21 | * used by the SimpleFlatFileMarshaler 22 | * @author Mayrbaeurl 23 | * @since 3.2 24 | */ 25 | public interface ContentConverter { 26 | 27 | /** 28 | * Converts the contents of column to the contents of the XML element 29 | * @param contents contents of the flat file column 30 | * @return contents for the XML element 31 | */ 32 | String convertToXml(String contents); 33 | 34 | /** 35 | * Converts the contents of a XML element to the contents of the flat file column 36 | * @param contents contents of the XML element 37 | * @return contents for the flat file 38 | */ 39 | String convertToFlatFileContent(String contents); 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/executors/impl/ManagedExecutorMBean.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.apache.servicemix.executors.impl; 20 | 21 | public interface ManagedExecutorMBean { 22 | 23 | int getActiveCount(); 24 | 25 | long getCompletedTaskCount(); 26 | 27 | int getCorePoolSize(); 28 | 29 | void setCorePoolSize(int size); 30 | 31 | long getKeepAliveTimeInMillis(); 32 | 33 | void setKeepAliveTimeInMillis(long timeInMillis); 34 | 35 | int getLargestPoolSize(); 36 | 37 | int getMaximumPoolSize(); 38 | 39 | void setMaximumPoolSize(int size); 40 | 41 | int getPoolSize(); 42 | 43 | long getTaskCount(); 44 | 45 | int getQueueSize(); 46 | 47 | boolean isAllowCoreThreadTimeOut(); 48 | 49 | long getNumberOfRejectedExecutions(); 50 | 51 | void reset(); 52 | 53 | long getShutdownDelay(); 54 | 55 | boolean isBypassIfSynchronous(); 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/api/ClientFactory.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.apache.servicemix.jbi.api; 18 | 19 | import javax.jbi.JBIException; 20 | 21 | 22 | /** 23 | * An interface that defines a factory to create ServiceMixClient. 24 | * An implementation should be bound in the JNDI context 25 | * 26 | * @author Guillaume Nodet 27 | */ 28 | public interface ClientFactory { 29 | 30 | /** 31 | * Default location to where the object should be looked for in JNDI 32 | */ 33 | String DEFAULT_JNDI_NAME = "org.apache.servicemix.jbi.ClientFactory"; 34 | 35 | /** 36 | * Create a new client to interact with the JBI bus 37 | * 38 | * @return a client 39 | * @throws JBIException if an error occurs 40 | */ 41 | ServiceMixClient createClient() throws JBIException; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/exception/NoFaultAvailableException.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.apache.servicemix.jbi.exception; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | 22 | /** 23 | * An exception thrown if a component cannot find an expected {@link Fault} 24 | * 25 | * @version $Revision: 564607 $ 26 | */ 27 | public class NoFaultAvailableException extends MessagingException { 28 | 29 | private final MessageExchange messageExchange; 30 | 31 | public NoFaultAvailableException(MessageExchange messageExchange) { 32 | super("No Fault available for message exchange: " + messageExchange); 33 | this.messageExchange = messageExchange; 34 | } 35 | 36 | /** 37 | * The message exchange on which the problem occurred 38 | */ 39 | public MessageExchange getMessageExchange() { 40 | return messageExchange; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/exception/NoInMessageAvailableException.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.apache.servicemix.jbi.exception; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | 22 | /** 23 | * An exception thrown if a component cannot find an expected in message. 24 | * 25 | * @version $Revision: 564374 $ 26 | */ 27 | public class NoInMessageAvailableException extends MessagingException { 28 | 29 | private final MessageExchange messageExchange; 30 | 31 | public NoInMessageAvailableException(MessageExchange messageExchange) { 32 | super("No in message available for message exchange: " + messageExchange); 33 | this.messageExchange = messageExchange; 34 | } 35 | 36 | /** 37 | * The message exchange on which the problem occurred 38 | */ 39 | public MessageExchange getMessageExchange() { 40 | return messageExchange; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/exception/NoOutMessageAvailableException.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.apache.servicemix.jbi.exception; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | 22 | /** 23 | * An exception thrown if a component cannot find an expected output message. 24 | * 25 | * @version $Revision: 564374 $ 26 | */ 27 | public class NoOutMessageAvailableException extends MessagingException { 28 | 29 | private final MessageExchange messageExchange; 30 | 31 | public NoOutMessageAvailableException(MessageExchange messageExchange) { 32 | super("No out message available for message exchange: " + messageExchange); 33 | this.messageExchange = messageExchange; 34 | } 35 | 36 | /** 37 | * The message exchange on which the problem occurred 38 | */ 39 | public MessageExchange getMessageExchange() { 40 | return messageExchange; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/executors/impl/WrappedRejectedExecutionHandler.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.apache.servicemix.executors.impl; 20 | 21 | import java.util.concurrent.RejectedExecutionHandler; 22 | import java.util.concurrent.ThreadPoolExecutor; 23 | 24 | public class WrappedRejectedExecutionHandler implements RejectedExecutionHandler { 25 | 26 | private RejectedExecutionHandler wrappedHandler; 27 | private ManagedExecutor executor; 28 | 29 | public WrappedRejectedExecutionHandler(ManagedExecutor executor) { 30 | this.executor = executor; 31 | this.wrappedHandler = this.executor.getInternalExecutor().getThreadPoolExecutor().getRejectedExecutionHandler(); 32 | } 33 | 34 | public void rejectedExecution(Runnable runnable, ThreadPoolExecutor threadPoolExecutor) { 35 | this.executor.increaseRejectedExecutions(); 36 | this.wrappedHandler.rejectedExecution(runnable, threadPoolExecutor); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/resources/log4j-tests.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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | # 22 | # The logging properties used during tests.. 23 | # 24 | log4j.rootLogger=DEBUG, out 25 | 26 | log4j.logger.org.springframework=INFO 27 | log4j.logger.org.apache.activemq=INFO 28 | log4j.logger.org.apache.activemq.spring=WARN 29 | log4j.logger.org.apache.activemq.store.journal=INFO 30 | log4j.logger.org.activeio.journal=INFO 31 | 32 | # CONSOLE appender not used by default 33 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 34 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 35 | log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 36 | 37 | # File appender 38 | log4j.appender.out=org.apache.log4j.FileAppender 39 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 40 | log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 41 | log4j.appender.out.file=target/servicemix-test.log 42 | log4j.appender.out.append=true 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/executors/Executor.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.apache.servicemix.executors; 18 | 19 | /** 20 | * The Executor interface is a simple interface 21 | * on top of a thread pool. 22 | * 23 | * @author Guillaume Nodet 24 | */ 25 | public interface Executor { 26 | 27 | /** 28 | * Execute a command. 29 | * 30 | * @param command the command to execute 31 | */ 32 | void execute(Runnable command); 33 | 34 | /** 35 | * Shutdown this executor. 36 | * This must be called to kill all threads. 37 | */ 38 | void shutdown(); 39 | 40 | /** 41 | * The capacity of the underlying queue (if any) 42 | * @return 43 | */ 44 | int capacity(); 45 | 46 | /** 47 | * The current size of the underlying queue (if any) 48 | * @return 49 | */ 50 | int size(); 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/test/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 14 | # implied. 15 | # 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | # 20 | 21 | # 22 | # The logging properties used during tests.. 23 | # 24 | log4j.rootLogger=DEBUG, out 25 | 26 | log4j.logger.org.springframework=INFO 27 | log4j.logger.org.apache.activemq=INFO 28 | log4j.logger.org.apache.activemq.spring=WARN 29 | log4j.logger.org.apache.activemq.store.journal=INFO 30 | log4j.logger.org.activeio.journal=INFO 31 | 32 | # CONSOLE appender not used by default 33 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 34 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 35 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n 36 | 37 | # File appender 38 | log4j.appender.out=org.apache.log4j.FileAppender 39 | log4j.appender.out.layout=org.apache.log4j.PatternLayout 40 | log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n 41 | log4j.appender.out.file=target/servicemix-test.log 42 | log4j.appender.out.append=true 43 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/PostgresqlJDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | import org.apache.servicemix.jdbc.Statements; 20 | 21 | 22 | /** 23 | * Implements all the default JDBC operations that are used 24 | * by the JDBCPersistenceAdapter. 25 | *

26 | * Subclassing is encouraged to override the default 27 | * implementation of methods to account for differences 28 | * in JDBC Driver implementations. 29 | *

30 | * The JDBCAdapter inserts and extracts BLOB data using the 31 | * getBytes()/setBytes() operations. 32 | *

33 | * The databases/JDBC drivers that use this adapter are: 34 | *

    35 | *
  • 36 | *
37 | * 38 | * @version $Revision: 1.1 $ 39 | */ 40 | public class PostgresqlJDBCAdapter extends BytesJDBCAdapter { 41 | 42 | public void setStatements(Statements statements) { 43 | statements.setBinaryDataType("BYTEA"); 44 | super.setStatements(statements); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/transformer/PropertyAddTransformer.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.apache.servicemix.jbi.transformer; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | 23 | public class PropertyAddTransformer extends CopyTransformer { 24 | 25 | String name; 26 | String value; 27 | 28 | public boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException { 29 | super.transform(exchange, in, out); 30 | out.setProperty(name, value); 31 | return true; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public String getValue() { 43 | return value; 44 | } 45 | 46 | public void setValue(String value) { 47 | this.value = value; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/expression/ExpressionEditorTest.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessagingException; 20 | 21 | import junit.framework.TestCase; 22 | 23 | import org.apache.xbean.spring.context.ClassPathXmlApplicationContext; 24 | import org.springframework.context.ApplicationContext; 25 | 26 | public class ExpressionEditorTest extends TestCase { 27 | 28 | private ApplicationContext context; 29 | 30 | @Override 31 | protected void setUp() throws Exception { 32 | context = new ClassPathXmlApplicationContext("/org/apache/servicemix/expression/expression-editor.xml"); 33 | } 34 | 35 | public void testSetAsTextString() throws MessagingException { 36 | ExpressionTestSupport support = (ExpressionTestSupport) context.getBean("ExpressionTestSupport"); 37 | assertTrue(support.getExpression() instanceof ConstantExpression); 38 | assertEquals("test", support.getExpression().evaluate(null, null)); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/jaxp/SourceMarshaler.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.apache.servicemix.jbi.jaxp; 18 | 19 | import java.io.StringWriter; 20 | 21 | import javax.xml.transform.Source; 22 | import javax.xml.transform.TransformerException; 23 | import javax.xml.transform.stream.StreamResult; 24 | 25 | /** 26 | * @version $Revision: 564374 $ 27 | */ 28 | public class SourceMarshaler { 29 | 30 | private SourceTransformer transformer = new SourceTransformer(); 31 | 32 | public Source asSource(String text) { 33 | return new StringSource(text); 34 | } 35 | 36 | public String asString(Source source) throws TransformerException { 37 | StringWriter buffer = new StringWriter(); 38 | transformer.toResult(source, new StreamResult(buffer)); 39 | return buffer.toString(); 40 | } 41 | 42 | public SourceTransformer getTransformer() { 43 | return transformer; 44 | } 45 | 46 | public void setTransformer(SourceTransformer transformer) { 47 | this.transformer = transformer; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/JAXPNodeSetXPathExpression.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | import javax.xml.xpath.XPathConstants; 23 | import javax.xml.xpath.XPathExpressionException; 24 | 25 | /** 26 | * Evaluates an XPath expression and coerces the result into a String. 27 | * 28 | * @version $Revision: 359151 $ 29 | */ 30 | public class JAXPNodeSetXPathExpression extends JAXPXPathExpression { 31 | 32 | public JAXPNodeSetXPathExpression() { 33 | } 34 | 35 | public JAXPNodeSetXPathExpression(String xpath) throws Exception { 36 | super(xpath); 37 | } 38 | 39 | public Object evaluateXPath(Object object) throws XPathExpressionException { 40 | return getXPathExpression().evaluate(object, XPathConstants.NODESET); 41 | } 42 | 43 | public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException { 44 | return evaluate(exchange, message, XPathConstants.NODESET); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/JAXPStringXPathExpression.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | import javax.xml.xpath.XPathConstants; 23 | import javax.xml.xpath.XPathExpressionException; 24 | 25 | /** 26 | * Evaluates an XPath expression and coerces the result into a String. 27 | * 28 | * @org.apache.xbean.XBean element="xpathString" 29 | * 30 | * @version $Revision: 654786 $ 31 | */ 32 | public class JAXPStringXPathExpression extends JAXPXPathExpression { 33 | 34 | public JAXPStringXPathExpression() { 35 | } 36 | 37 | public JAXPStringXPathExpression(String xpath) { 38 | super(xpath); 39 | } 40 | 41 | public Object evaluateXPath(Object object) throws XPathExpressionException { 42 | return getXPathExpression().evaluate(object, XPathConstants.STRING); 43 | } 44 | 45 | public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException { 46 | return evaluate(exchange, message, XPathConstants.STRING); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/BytesJDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | import java.sql.PreparedStatement; 20 | import java.sql.ResultSet; 21 | import java.sql.SQLException; 22 | 23 | /** 24 | * This JDBCAdapter inserts and extracts BLOB data using the 25 | * setBytes()/getBytes() operations. 26 | * 27 | * The databases/JDBC drivers that use this adapter are: 28 | * 29 | * @org.apache.xbean.XBean element="bytesJDBCAdapter" 30 | * 31 | * @version $Revision: 1.2 $ 32 | */ 33 | public class BytesJDBCAdapter extends DefaultJDBCAdapter { 34 | 35 | /** 36 | * @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#getBinaryData(java.sql.ResultSet, int) 37 | */ 38 | protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException { 39 | return rs.getBytes(index); 40 | } 41 | 42 | /** 43 | * @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#setBinaryData(java.sql.PreparedStatement, int, byte[]) 44 | */ 45 | protected void setBinaryData(PreparedStatement s, int index, byte[] data) throws SQLException { 46 | s.setBytes(index, data); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/JAXPBooleanXPathExpression.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | import javax.xml.xpath.XPathConstants; 23 | import javax.xml.xpath.XPathExpressionException; 24 | 25 | /** 26 | * Evaluates an XPath expression and coerces the result into a String. 27 | * 28 | * @org.apache.xbean.XBean element="xpathBoolean" 29 | * 30 | * @version $Revision: 359151 $ 31 | */ 32 | public class JAXPBooleanXPathExpression extends JAXPXPathExpression { 33 | 34 | public JAXPBooleanXPathExpression() { 35 | } 36 | 37 | public JAXPBooleanXPathExpression(String xpath) throws Exception { 38 | super(xpath); 39 | } 40 | 41 | public Object evaluateXPath(Object object) throws XPathExpressionException { 42 | return getXPathExpression().evaluate(object, XPathConstants.BOOLEAN); 43 | } 44 | 45 | public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException { 46 | return evaluate(exchange, message, XPathConstants.BOOLEAN); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/OracleJDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | import java.sql.Blob; 20 | import java.sql.ResultSet; 21 | import java.sql.SQLException; 22 | 23 | /** 24 | * Implements all the default JDBC operations that are used 25 | * by the JDBCPersistenceAdapter. 26 | *

27 | * Subclassing is encouraged to override the default 28 | * implementation of methods to account for differences 29 | * in JDBC Driver implementations. 30 | *

31 | * The JDBCAdapter inserts and extracts BLOB data using the 32 | * getBytes()/setBytes() operations. 33 | *

34 | * The databases/JDBC drivers that use this adapter are: 35 | *

    36 | *
  • 37 | *
38 | * 39 | * @org.apache.xbean.XBean element="oracleJDBCAdapter" 40 | * 41 | * @version $Revision: 1.2 $ 42 | */ 43 | public class OracleJDBCAdapter extends DefaultJDBCAdapter { 44 | 45 | protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException { 46 | // Get as a BLOB 47 | Blob aBlob = rs.getBlob(index); 48 | if (aBlob == null) { 49 | return null; 50 | } 51 | return aBlob.getBytes(1, (int) aBlob.length()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/jaxp/BytesSource.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.apache.servicemix.jbi.jaxp; 18 | 19 | import java.io.ByteArrayInputStream; 20 | import java.io.InputStream; 21 | import java.io.InputStreamReader; 22 | import java.io.Reader; 23 | 24 | import javax.xml.transform.stream.StreamSource; 25 | 26 | /** 27 | * A helper class which provides a JAXP {@link javax.xml.transform.Source} from a byte[] 28 | * which can be read as many times as required. 29 | * 30 | * @version $Revision: 564607 $ 31 | */ 32 | public class BytesSource extends StreamSource { 33 | private byte[] data; 34 | 35 | public BytesSource(byte[] data) { 36 | this.data = data; 37 | } 38 | 39 | public BytesSource(byte[] data, String systemId) { 40 | this.data = data; 41 | setSystemId(systemId); 42 | } 43 | 44 | public InputStream getInputStream() { 45 | return new ByteArrayInputStream(data); 46 | } 47 | 48 | public Reader getReader() { 49 | return new InputStreamReader(getInputStream()); 50 | } 51 | 52 | public byte[] getData() { 53 | return data; 54 | } 55 | 56 | public String toString() { 57 | return "BytesSource[" + new String(data) + "]"; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/jaxp/QNameHelper.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.apache.servicemix.jbi.jaxp; 18 | 19 | import javax.xml.namespace.NamespaceContext; 20 | import javax.xml.namespace.QName; 21 | 22 | /** 23 | * @version $Revision: 1.1 $ 24 | */ 25 | public final class QNameHelper { 26 | 27 | private QNameHelper() { 28 | } 29 | 30 | public static String getQualifiedName(QName qname) { 31 | String prefix = qname.getPrefix(); 32 | String localPart = qname.getLocalPart(); 33 | if (prefix != null && prefix.length() > 0) { 34 | return prefix + ":" + localPart; 35 | } 36 | return localPart; 37 | } 38 | 39 | /** 40 | * Turns the given String into a QName using the current namespace context 41 | */ 42 | public static QName asQName(NamespaceContext context, String text) { 43 | int idx = text.indexOf(':'); 44 | if (idx >= 0) { 45 | String prefix = text.substring(0, idx); 46 | String localPart = text.substring(idx + 1); 47 | String uri = context.getNamespaceURI(prefix); 48 | return new QName(uri, localPart, prefix); 49 | } else { 50 | return new QName(text); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/jaxp/ResourceSource.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.apache.servicemix.jbi.jaxp; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.InputStreamReader; 22 | import java.io.Reader; 23 | 24 | import javax.xml.transform.stream.StreamSource; 25 | 26 | import org.springframework.core.io.Resource; 27 | 28 | /** 29 | * A JAXP {@link StreamSource} which uses a Spring {@link Resource} as the source of the input stream. 30 | * This implementation is re-entrant and can be used as many times as required to parse XML. 31 | * 32 | * @version $Revision: 564607 $ 33 | */ 34 | public class ResourceSource extends StreamSource { 35 | 36 | private final Resource resource; 37 | 38 | public ResourceSource(Resource resource) { 39 | this.resource = resource; 40 | } 41 | 42 | public InputStream getInputStream() { 43 | try { 44 | return resource.getInputStream(); 45 | } catch (IOException e) { 46 | throw new RuntimeException("Failed to open resource: " + resource + ". Reason: " + e, e); 47 | } 48 | } 49 | 50 | public Reader getReader() { 51 | return new InputStreamReader(getInputStream()); 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/components/util/MarshalerSupport.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.apache.servicemix.components.util; 18 | 19 | import org.apache.servicemix.jbi.jaxp.SourceTransformer; 20 | 21 | /** 22 | * A useful base class for some kind of marshaler to and from JBI NormalizedMessage instances to 23 | * some kind of underlying transport or protocol. 24 | * 25 | * @version $Revision: 673769 $ 26 | */ 27 | public class MarshalerSupport { 28 | private SourceTransformer transformer; 29 | 30 | /** 31 | * Converts the value to a String 32 | * 33 | * @param value the value to be coerced into a string 34 | * @return the value as a string or null if it cannot be converted 35 | */ 36 | protected String asString(Object value) { 37 | return value != null ? value.toString() : null; 38 | } 39 | 40 | // Properties 41 | //------------------------------------------------------------------------- 42 | public SourceTransformer getTransformer() { 43 | if (transformer == null) { 44 | transformer = new SourceTransformer(); 45 | } 46 | return transformer; 47 | } 48 | 49 | public void setTransformer(SourceTransformer transformer) { 50 | this.transformer = transformer; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/converter/ConvertersTest.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.apache.servicemix.converter; 18 | 19 | import org.junit.Test; 20 | import static org.junit.Assert.*; 21 | 22 | /** 23 | * Test cases for {@link Converters} 24 | */ 25 | public class ConvertersTest { 26 | 27 | private final Converters converters = new Converters(); 28 | 29 | @Test 30 | public void testIntegers() { 31 | assertEquals((Integer) 10, converters.as(10, Integer.class)); 32 | assertEquals((Integer) 10, converters.as("10", Integer.class)); 33 | assertEquals(null, converters.as("ILLEGAL_VALUE", Integer.class)); 34 | } 35 | 36 | @Test 37 | public void testLongs() { 38 | assertEquals((Long) 10l, converters.as(10l, Long.class)); 39 | assertEquals((Long) 10l, converters.as(10, Long.class)); 40 | assertEquals((Long) 10l, converters.as("10", Long.class)); 41 | assertEquals(null, converters.as("ILLEGAL_VALUE", Long.class)); 42 | } 43 | 44 | @Test 45 | public void testBooleans() { 46 | assertEquals(true, converters.as(true, Boolean.class)); 47 | assertEquals(false, converters.as("false", Boolean.class)); 48 | assertEquals(null, converters.as("ILLEGAL_VALUE", Boolean.class)); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/exception/FaultException.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.apache.servicemix.jbi.exception; 18 | 19 | import javax.jbi.messaging.Fault; 20 | import javax.jbi.messaging.MessageExchange; 21 | import javax.jbi.messaging.MessagingException; 22 | 23 | /** 24 | * An exception which is thrown if a fault occurs in some JBI client invocation. 25 | * 26 | * @version $Revision: 564374 $ 27 | */ 28 | public class FaultException extends MessagingException { 29 | 30 | private final MessageExchange exchange; 31 | private final Fault fault; 32 | 33 | public FaultException(String text, MessageExchange exchange, Fault fault) { 34 | super(text); 35 | this.exchange = exchange; 36 | this.fault = fault; 37 | } 38 | 39 | public static FaultException newInstance(MessageExchange exchange) throws NoFaultAvailableException { 40 | Fault fault = exchange.getFault(); 41 | if (fault == null) { 42 | throw new NoFaultAvailableException(exchange); 43 | } else { 44 | return new FaultException("Fault occurred invoking server: " + fault, exchange, fault); 45 | } 46 | } 47 | 48 | public MessageExchange getExchange() { 49 | return exchange; 50 | } 51 | 52 | public Fault getFault() { 53 | return fault; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/store/Entry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 iocanel. 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 | * under the License. 16 | */ 17 | package org.apache.servicemix.store; 18 | 19 | import java.io.Serializable; 20 | 21 | /** 22 | * 23 | * @author iocanel 24 | */ 25 | public class Entry implements Serializable { 26 | 27 | private final long time = System.currentTimeMillis(); 28 | private final Object data; 29 | 30 | public Entry(Object data) { 31 | this.data = data; 32 | } 33 | 34 | public long getTime() { 35 | return time; 36 | } 37 | 38 | public Object getData() { 39 | return data; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Entry{" + "time=" + time + ", data=" + data + '}'; 45 | } 46 | 47 | @Override 48 | public boolean equals(Object obj) { 49 | if (obj == null) { 50 | return false; 51 | } 52 | if (getClass() != obj.getClass()) { 53 | return false; 54 | } 55 | final Entry other = (Entry) obj; 56 | if (this.time != other.time) { 57 | return false; 58 | } 59 | if (this.data != other.data && (this.data == null || !this.data.equals(other.data))) { 60 | return false; 61 | } 62 | return true; 63 | } 64 | 65 | @Override 66 | public int hashCode() { 67 | int hash = 7; 68 | hash = 53 * hash + (int) (this.time ^ (this.time >>> 32)); 69 | hash = 53 * hash + (this.data != null ? this.data.hashCode() : 0); 70 | return hash; 71 | } 72 | 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/transformer/MessageTransformer.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.apache.servicemix.jbi.transformer; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | 23 | /** 24 | * Represents a transformer of an input message into an output message 25 | * 26 | * @version $Revision: 426415 $ 27 | */ 28 | public interface MessageTransformer { 29 | 30 | /** 31 | * Transfers the state in the input message into the output message 32 | * @param exchange the exchange on which the messages are flowing 33 | * @param in the input message 34 | * @param out an empty out message ready to contain the result of the transformation 35 | */ 36 | boolean transform(MessageExchange exchange, NormalizedMessage in, NormalizedMessage out) throws MessagingException; 37 | 38 | /** 39 | * Transforms an input message into the returned output message 40 | * 41 | * @param exchange the exchange fon which the messages are flowing 42 | * @param in the input message 43 | * @return the output message or null if the output message co 44 | * @throws MessagingException when an error occurs while transforming the message 45 | */ 46 | NormalizedMessage transform(MessageExchange exchange, NormalizedMessage in) throws MessagingException; 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/store/jdbc/JdbcStoreTest.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.apache.servicemix.store.jdbc; 18 | 19 | import java.sql.Connection; 20 | 21 | import javax.sql.DataSource; 22 | 23 | import junit.framework.TestCase; 24 | 25 | import org.apache.servicemix.store.Store; 26 | import org.apache.servicemix.store.StoreFactory; 27 | import org.hsqldb.jdbc.jdbcDataSource; 28 | 29 | public class JdbcStoreTest extends TestCase { 30 | 31 | private DataSource dataSource; 32 | private Connection connection; 33 | private StoreFactory factory; 34 | 35 | protected void setUp() throws Exception { 36 | jdbcDataSource ds = new jdbcDataSource(); 37 | ds.setDatabase("jdbc:hsqldb:mem:aname"); 38 | ds.setUser("sa"); 39 | dataSource = ds; 40 | connection = dataSource.getConnection(); 41 | JdbcStoreFactory f = new JdbcStoreFactory(); 42 | f.setDataSource(dataSource); 43 | factory = f; 44 | } 45 | 46 | protected void tearDown() throws Exception { 47 | if (connection != null) { 48 | connection.close(); 49 | } 50 | } 51 | 52 | public void testStoreLoad() throws Exception { 53 | Store store = factory.open("store"); 54 | String id = store.store(new Integer(10)); 55 | Integer i = (Integer) store.load(id); 56 | assertEquals(10, i.intValue()); 57 | assertNull(store.load("a")); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/ExpressionHelper.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | 23 | /** 24 | * A helper class for working with expressions. 25 | * 26 | * @version $Revision: 564374 $ 27 | */ 28 | public final class ExpressionHelper { 29 | 30 | private ExpressionHelper() { 31 | } 32 | 33 | /** 34 | * Evaluates the given expression as a string value. 35 | * 36 | * @param expression the expression to evaluate 37 | * @param exchange the current exchange 38 | * @param message the current message 39 | * @param defaultValue the default value to use if the expression is null or the value of the expression is null 40 | * @return the value of the expression as a string if it is not null or the defaultValue 41 | * @throws MessagingException if the expression failed to be evaluated 42 | */ 43 | public static String asString(Expression expression, MessageExchange exchange, 44 | NormalizedMessage message, String defaultValue) throws MessagingException { 45 | if (expression != null) { 46 | Object answer = expression.evaluate(exchange, message); 47 | if (answer != null) { 48 | return answer.toString(); 49 | } 50 | } 51 | return defaultValue; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/XMLBeansStringXPathExpression.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.apache.servicemix.expression; 18 | 19 | import org.apache.xmlbeans.XmlCursor; 20 | import org.apache.xmlbeans.XmlObject; 21 | import org.apache.xmlbeans.XmlOptions; 22 | 23 | /** 24 | * An {@link Expression} which evaluates an XPath expression using XMLBeans and 25 | * returns the String value. 26 | * 27 | * @version $Revision: 564374 $ 28 | */ 29 | public class XMLBeansStringXPathExpression extends XMLBeansXPathExpression { 30 | public XMLBeansStringXPathExpression(String xpath) { 31 | super(xpath); 32 | } 33 | 34 | protected Object evaluateXPath(XmlObject object, String xpath, XmlOptions options) { 35 | XmlObject[] xmlObjects = object.selectPath(xpath); 36 | if (xmlObjects == null || xmlObjects.length == 0) { 37 | return ""; 38 | } else if (xmlObjects.length == 1) { 39 | return asString(xmlObjects[0]); 40 | } else { 41 | StringBuffer buffer = new StringBuffer(); 42 | for (int i = 0; i < xmlObjects.length; i++) { 43 | XmlObject xmlObject = xmlObjects[i]; 44 | buffer.append(asString(xmlObject)); 45 | } 46 | return buffer.toString(); 47 | } 48 | } 49 | 50 | protected String asString(XmlObject xmlObject) { 51 | XmlCursor cursor = xmlObject.newCursor(); 52 | return cursor.getTextValue(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/util/jaf/ByteArrayDataSource.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.apache.servicemix.util.jaf; 18 | 19 | import java.io.ByteArrayInputStream; 20 | import java.io.IOException; 21 | import java.io.InputStream; 22 | import java.io.OutputStream; 23 | import java.io.Serializable; 24 | 25 | import javax.activation.DataSource; 26 | 27 | /** 28 | * Byte array DataSource for Mail and message attachments 29 | * 30 | * @author George Gastaldi 31 | * @since 3.0 32 | */ 33 | public class ByteArrayDataSource implements DataSource, Serializable { 34 | 35 | private static final long serialVersionUID = 1L; 36 | 37 | private byte[] data; 38 | private String contentType; 39 | private String name = "unused"; 40 | 41 | public ByteArrayDataSource(byte[] data, String contentType) { 42 | this.data = data; 43 | this.contentType = contentType; 44 | } 45 | 46 | public InputStream getInputStream() throws IOException { 47 | if (data == null) { 48 | throw new IOException("no data"); 49 | } 50 | return new ByteArrayInputStream(data); 51 | } 52 | 53 | public OutputStream getOutputStream() throws IOException { 54 | throw new IOException("getOutputStream() not supported"); 55 | } 56 | 57 | public String getContentType() { 58 | return contentType; 59 | } 60 | 61 | public String getName() { 62 | return name; 63 | } 64 | 65 | public void setName(String name) { 66 | this.name = name; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/expression/JAXPXPathXStreamExpressionTest.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.apache.servicemix.expression; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | import javax.jbi.messaging.MessageExchange; 22 | import javax.jbi.messaging.MessagingException; 23 | import javax.jbi.messaging.NormalizedMessage; 24 | 25 | import junit.framework.TestCase; 26 | 27 | import com.thoughtworks.xstream.XStream; 28 | 29 | import org.apache.servicemix.jbi.jaxp.StringSource; 30 | import org.apache.servicemix.tck.mock.MockMessageExchange; 31 | 32 | 33 | /** 34 | * @version $Revision: 659786 $ 35 | */ 36 | public class JAXPXPathXStreamExpressionTest extends TestCase { 37 | XStream xStream = new XStream(); 38 | 39 | public void testMap() throws Exception { 40 | JAXPXPathXStreamExpression exp = new JAXPXPathXStreamExpression(); 41 | Map params = new HashMap(); 42 | params.put("key1", "value1"); 43 | exp.setXPath("/header/map"); 44 | assertExpression(exp, params, "
" + xStream.toXML(params) + "
"); 45 | } 46 | 47 | protected void assertExpression(Expression expression, Object expected, String xml) throws MessagingException { 48 | MessageExchange exchange = new MockMessageExchange(); 49 | NormalizedMessage message = exchange.createMessage(); 50 | message.setContent(new StringSource(xml)); 51 | Object value = expression.evaluate(exchange, message); 52 | assertEquals("Expression: " + expression, expected, value); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/executors/impl/ExecutorFactoryImplTest.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.apache.servicemix.executors.impl; 18 | 19 | import org.apache.servicemix.executors.ExecutorFactory; 20 | import org.junit.Before; 21 | import org.junit.Test; 22 | 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | 26 | import static org.junit.Assert.*; 27 | 28 | /** 29 | * Test cases for {@link ExecutorFactoryImpl} 30 | */ 31 | public class ExecutorFactoryImplTest { 32 | 33 | private ExecutorConfig defaultConfig; 34 | private ExecutorFactoryImpl factory; 35 | 36 | @Before 37 | public void setupExecutorFactory() { 38 | factory = new ExecutorFactoryImpl(); 39 | 40 | defaultConfig = new ExecutorConfig(); 41 | defaultConfig.setCorePoolSize(1); 42 | defaultConfig.setMaximumPoolSize(2); 43 | defaultConfig.setQueueSize(3); 44 | defaultConfig.setAllowCoreThreadTimeOut(true); 45 | factory.setDefaultConfig(defaultConfig); 46 | } 47 | 48 | @Test 49 | public void testAdditionalConfig() { 50 | Map config = new HashMap(); 51 | config.put(ExecutorFactory.MAXIMUM_POOL_SIZE, 10); 52 | ExecutorImpl impl = (ExecutorImpl) factory.createExecutor("test", config); 53 | assertEquals("Core pool size is the default", 54 | defaultConfig.getCorePoolSize(), impl.getConfig().getCorePoolSize()); 55 | assertEquals("Maximum pool size has been altered", 56 | new Integer(10), impl.getConfig().getMaximumPoolSize()); 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/api/EndpointResolver.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.apache.servicemix.jbi.api; 18 | 19 | import javax.jbi.JBIException; 20 | import javax.jbi.component.ComponentContext; 21 | import javax.jbi.messaging.MessageExchange; 22 | import javax.jbi.servicedesc.ServiceEndpoint; 23 | 24 | /** 25 | * A Strategy pattern which can be used to plug in different {@link ServiceEndpoint} resolving policies from static 26 | * relationships to dynamic resolution of the endpoint used based on some policy. 27 | * 28 | * @version $Revision: 426415 $ 29 | */ 30 | public interface EndpointResolver { 31 | 32 | /** 33 | * Resolves the endpoint which should be used for the given message exchange 34 | * using either a hard coded endpoint or some policy which chooses the endpoint 35 | * dynamically using some algorithm. 36 | * 37 | * @param context is the component context 38 | * @param exchange the message exchange which the endpoint will be used for which may 39 | * contain some state to help choose the algorithm. 40 | * @param filter the filter to be applied to the available endpoints 41 | * @return the chosen endpoint or null if no endpoint could be found. 42 | */ 43 | ServiceEndpoint resolveEndpoint(ComponentContext context, MessageExchange exchange, EndpointFilter filter) throws JBIException; 44 | 45 | /** 46 | * Resolves all the available endpoints which may not be applicable to a component. 47 | */ 48 | ServiceEndpoint[] resolveAvailableEndpoints(ComponentContext context, MessageExchange exchange) throws JBIException; 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/JDBCAdapter.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.apache.servicemix.jdbc; 18 | 19 | import java.io.IOException; 20 | import java.sql.Connection; 21 | import java.sql.SQLException; 22 | import java.util.Map; 23 | 24 | public interface JDBCAdapter { 25 | 26 | void doCreateTables(Connection connection) throws SQLException, IOException; 27 | 28 | void doDropTables(Connection connection) throws SQLException, IOException; 29 | 30 | byte[] doLoadData(Connection connection, String id) throws SQLException, IOException; 31 | 32 | byte[][] doLoadData(Connection connection, String[] ids) throws SQLException, IOException; 33 | 34 | Map doLoadData(Connection connection) throws SQLException, IOException; 35 | 36 | void doStoreData(Connection connection, String id, byte[] data) throws SQLException, IOException; 37 | 38 | void doUpdateData(Connection connection, String id, byte[] data) throws SQLException, IOException; 39 | 40 | void doRemoveData(Connection connection, String id) throws SQLException, IOException; 41 | 42 | void doRemoveData(Connection connection, String[] ids) throws SQLException, IOException; 43 | 44 | int doGetCount(Connection connection) throws SQLException, IOException; 45 | 46 | String[] doGetIds(Connection connection) throws SQLException, IOException; 47 | 48 | String[] doGetIds(Connection connection, int fromIndex, int toIndex) throws SQLException, IOException; 49 | 50 | Statements getStatements(); 51 | 52 | void setStatements(Statements statements); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/api/Message.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.apache.servicemix.jbi.api; 18 | 19 | import javax.jbi.messaging.Fault; 20 | import javax.jbi.messaging.MessageExchange; 21 | import javax.jbi.messaging.MessagingException; 22 | import javax.jbi.messaging.NormalizedMessage; 23 | 24 | import org.apache.servicemix.jbi.marshaler.PojoMarshaler; 25 | 26 | /** 27 | * An extension of the standard {@link NormalizedMessage} which allows you to 28 | * work directly with message bodies as POJOs ignoring the XML stuff or passing a binary 29 | * message around as a ByteBuffer or byte[] 30 | * 31 | * @version $Revision: 359151 $ 32 | */ 33 | public interface Message extends NormalizedMessage { 34 | 35 | /** 36 | * Returns the body as a POJO. Depending on the implementation this could be 37 | * a Java POJO, a DOM tree or a byte[] 38 | */ 39 | Object getBody() throws MessagingException; 40 | 41 | /** 42 | * Returns the body as a POJO. Depending on the implementation this could be 43 | * a Java POJO, a DOM tree or a byte[] 44 | * 45 | * @param marshaler marshaler to be used for conversion 46 | */ 47 | Object getBody(PojoMarshaler marshaler) throws MessagingException; 48 | 49 | /** 50 | * Sets the body as a POJO 51 | */ 52 | void setBody(Object body) throws MessagingException; 53 | 54 | /** 55 | * Returns the message exchange 56 | */ 57 | MessageExchange getExchange(); 58 | 59 | /** 60 | * Helper method to create a new fault for this message exchange 61 | */ 62 | Fault createFault() throws MessagingException; 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/jbi/transformer/CopyTransformerTest.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.apache.servicemix.jbi.transformer; 18 | 19 | import java.io.Reader; 20 | import java.io.StringReader; 21 | 22 | import javax.jbi.messaging.NormalizedMessage; 23 | import javax.xml.transform.Source; 24 | import javax.xml.transform.sax.SAXSource; 25 | import javax.xml.transform.stream.StreamSource; 26 | 27 | import org.xml.sax.InputSource; 28 | 29 | import junit.framework.TestCase; 30 | 31 | import org.apache.servicemix.jbi.helper.MessageUtil; 32 | import org.apache.servicemix.jbi.jaxp.SourceTransformer; 33 | 34 | public class CopyTransformerTest extends TestCase { 35 | 36 | private CopyTransformer transformer = CopyTransformer.getInstance(); 37 | 38 | public void testWithSAXSource() throws Exception { 39 | Reader r = new StringReader("world"); 40 | Source src = new SAXSource(new InputSource(r)); 41 | NormalizedMessage msg = copyMessage(src); 42 | r.close(); 43 | new SourceTransformer().contentToString(msg); 44 | } 45 | 46 | public void testWithStreamSource() throws Exception { 47 | Reader r = new StringReader("world"); 48 | Source src = new StreamSource(r); 49 | NormalizedMessage msg = copyMessage(src); 50 | r.close(); 51 | new SourceTransformer().contentToString(msg); 52 | } 53 | 54 | protected NormalizedMessage copyMessage(Source src) throws Exception { 55 | NormalizedMessage from = new MessageUtil.NormalizedMessageImpl(); 56 | NormalizedMessage to = new MessageUtil.NormalizedMessageImpl(); 57 | from.setContent(src); 58 | transformer.transform(null, from, to); 59 | return to; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/util/jaf/StreamDataSource.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.apache.servicemix.util.jaf; 18 | 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | 23 | import javax.activation.DataSource; 24 | 25 | /** 26 | * Stream DataSource for Mail and message attachments . 27 | * 28 | * @author Guillaume Nodet 29 | * @since 3.0 30 | */ 31 | public class StreamDataSource implements DataSource { 32 | 33 | private InputStream in; 34 | 35 | private String contentType; 36 | 37 | private String name; 38 | 39 | public StreamDataSource(InputStream in) { 40 | this(in, null, null); 41 | } 42 | 43 | public StreamDataSource(InputStream in, String contentType) { 44 | this(in, contentType, null); 45 | } 46 | 47 | public StreamDataSource(InputStream in, String contentType, String name) { 48 | this.in = in; 49 | this.contentType = contentType; 50 | this.name = name; 51 | } 52 | 53 | public InputStream getInputStream() throws IOException { 54 | if (in == null) { 55 | throw new IOException("no data"); 56 | } 57 | return in; 58 | } 59 | 60 | public OutputStream getOutputStream() throws IOException { 61 | throw new IOException("getOutputStream() not supported"); 62 | } 63 | 64 | public String getContentType() { 65 | return contentType; 66 | } 67 | 68 | public String getName() { 69 | return name; 70 | } 71 | 72 | public void setName(String name) { 73 | this.name = name; 74 | } 75 | 76 | public void setContentType(String contentType) { 77 | this.contentType = contentType; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/store/redis/RedisStoreFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 iocanel. 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 | * under the License. 16 | */ 17 | package org.apache.servicemix.store.redis; 18 | 19 | 20 | import org.apache.servicemix.store.Store; 21 | import org.apache.servicemix.store.StoreListener; 22 | import org.apache.servicemix.store.base.BaseStoreFactory; 23 | import org.idevlab.rjc.RedisNode; 24 | 25 | import java.io.IOException; 26 | import java.util.HashMap; 27 | import java.util.Map; 28 | 29 | public class RedisStoreFactory extends BaseStoreFactory { 30 | 31 | private Map stores = new HashMap(); 32 | 33 | private RedisNode redisNode; 34 | private long timeout = -1; 35 | 36 | public static final String STORE_PREFIX = "org.apache.servicemix.stores"; 37 | 38 | public RedisStoreFactory(RedisNode redisNode) { 39 | this.redisNode = redisNode; 40 | } 41 | 42 | public synchronized Store open(String name) throws IOException { 43 | RedisStore store = stores.get(name); 44 | String storeName = STORE_PREFIX + "." + name; 45 | if (store == null) { 46 | if (timeout <= 0) { 47 | store = new RedisStore(redisNode, storeName); 48 | } else { 49 | store = new RedisStore(redisNode, storeName, timeout); 50 | } 51 | 52 | for(StoreListener listener:storeListeners) { 53 | store.addListener(listener); 54 | } 55 | stores.put(name, store); 56 | } 57 | return store; 58 | } 59 | 60 | /* (non-Javadoc) 61 | * @see org.apache.servicemix.store.ExchangeStoreFactory#release(org.apache.servicemix.store.ExchangeStore) 62 | */ 63 | public synchronized void close(Store store) throws IOException { 64 | stores.remove(store); 65 | } 66 | 67 | public long getTimeout() { 68 | return timeout; 69 | } 70 | 71 | public void setTimeout(long timeout) { 72 | this.timeout = timeout; 73 | } 74 | } -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/jbi/jaxp/WsRfRpTest.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.apache.servicemix.jbi.jaxp; 18 | 19 | import javax.xml.transform.Source; 20 | import javax.xml.bind.util.JAXBSource; 21 | import javax.xml.bind.JAXBElement; 22 | import javax.xml.bind.JAXBContext; 23 | import javax.xml.bind.annotation.XmlRegistry; 24 | import javax.xml.bind.annotation.XmlElementDecl; 25 | import javax.xml.namespace.QName; 26 | import javax.xml.stream.XMLStreamReader; 27 | 28 | import junit.framework.TestCase; 29 | 30 | public class WsRfRpTest extends TestCase { 31 | 32 | public void test() throws Exception { 33 | JAXBContext context = JAXBContext.newInstance(ObjectFactory.class); 34 | Source source = new JAXBSource(context, new ObjectFactory().createGetResourceProperty(new QName("urn", "local"))); 35 | XMLStreamReader reader = new SourceTransformer().toXMLStreamReader(source); 36 | reader.nextTag(); 37 | source = new StaxSource(new FragmentStreamReader(reader)); 38 | 39 | @SuppressWarnings("unchecked") 40 | JAXBElement e = (JAXBElement) context.createUnmarshaller().unmarshal(source); 41 | assertNotNull(e.getValue()); 42 | System.out.println(e.getValue()); 43 | } 44 | 45 | @XmlRegistry 46 | public static class ObjectFactory { 47 | 48 | private final static QName _GetResourceProperty_QNAME = new QName("http://docs.oasis-open.org/wsrf/rp-2", "GetResourceProperty"); 49 | 50 | @XmlElementDecl(namespace = "http://docs.oasis-open.org/wsrf/rp-2", name = "GetResourceProperty") 51 | public JAXBElement createGetResourceProperty(QName value) { 52 | return new JAXBElement(_GetResourceProperty_QNAME, QName.class, null, value); 53 | } 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/test/resources/org/apache/servicemix/jbi/jaxp/test.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | world 22 | 23 | 24 | t i u 25 | 26 | 27 | 28 | 00 01 02 03 04 05 06 07 08 09 29 | 10 11 12 13 14 15 16 17 18 19 30 | 20 21 22 23 24 25 26 27 28 29 31 | 30 31 32 33 34 35 36 37 38 39 32 | 40 41 42 43 44 45 46 47 48 49 33 | 50 51 52 53 54 55 56 57 58 59 34 | 60 61 62 63 64 65 66 67 68 69 35 | 70 71 72 73 74 75 76 77 78 79 36 | 80 81 82 83 84 85 86 87 88 89 37 | 90 91 92 93 94 95 96 97 98 99 38 | 00 01 02 03 04 05 06 07 08 09 39 | 10 11 12 13 14 15 16 17 18 19 40 | 20 21 22 23 24 25 26 27 28 29 41 | 30 31 32 33 34 35 36 37 38 39 42 | 40 41 42 43 44 45 46 47 48 49 43 | 50 51 52 53 54 55 56 57 58 59 44 | 60 61 62 63 64 65 66 67 68 69 45 | 70 71 72 73 74 75 76 77 78 79 46 | 80 81 82 83 84 85 86 87 88 89 47 | 90 91 92 93 94 95 96 97 98 99 48 | 00 01 02 03 04 05 06 07 08 09 49 | 10 11 12 13 14 15 16 17 18 19 50 | 20 21 22 23 24 25 26 27 28 29 51 | 30 31 32 33 34 35 36 37 38 39 52 | 40 41 42 43 44 45 46 47 48 49 53 | 50 51 52 53 54 55 56 57 58 59 54 | 60 61 62 63 64 65 66 67 68 69 55 | 70 71 72 73 74 75 76 77 78 79 56 | 80 81 82 83 84 85 86 87 88 89 57 | 90 91 92 93 94 95 96 97 98 99 58 | 00 01 02 03 04 05 06 07 08 09 59 | 10 11 12 13 14 15 16 17 18 19 60 | 20 21 22 23 24 25 26 27 28 29 61 | 30 31 32 33 34 35 36 37 38 39 62 | 40 41 42 43 44 45 46 47 48 49 63 | 50 51 52 53 54 55 56 57 58 59 64 | 60 61 62 63 64 65 66 67 68 69 65 | 70 71 72 73 74 75 76 77 78 79 66 | 80 81 82 83 84 85 86 87 88 89 67 | 90 91 92 93 94 95 96 97 98 99 68 | 69 | 70 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/api/Destination.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.apache.servicemix.jbi.api; 18 | 19 | import javax.jbi.messaging.InOnly; 20 | import javax.jbi.messaging.InOptionalOut; 21 | import javax.jbi.messaging.InOut; 22 | import javax.jbi.messaging.MessagingException; 23 | import javax.jbi.messaging.RobustInOnly; 24 | 25 | /** 26 | * Represents a JBI endpoint you can communicate with 27 | * 28 | * @version $Revision: $ 29 | */ 30 | public interface Destination { 31 | 32 | /** 33 | * Creates an {@link InOnly} (one way) message exchange. 34 | * 35 | * @return the newly created message exchange 36 | * @throws MessagingException 37 | */ 38 | InOnly createInOnlyExchange() throws MessagingException; 39 | 40 | /** 41 | * Creates an {@link InOut} (request-reply) message exchange. 42 | * 43 | * @return the newly created message exchange 44 | * @throws MessagingException 45 | */ 46 | InOut createInOutExchange() throws MessagingException; 47 | 48 | /** 49 | * Creates an {@link InOptionalOut} (optional request-reply) message 50 | * exchange. 51 | * 52 | * @return the newly created message exchange 53 | * @throws MessagingException 54 | */ 55 | InOptionalOut createInOptionalOutExchange() throws MessagingException; 56 | 57 | /** 58 | * Creates an {@link RobustInOnly} (one way) message exchange. 59 | * 60 | * @return the newly created message exchange 61 | * @throws MessagingException 62 | */ 63 | RobustInOnly createRobustInOnlyExchange() throws MessagingException; 64 | 65 | /** 66 | * Allows a Message to be created for an {@link InOnly} exchange for simpler one-way messaging. 67 | * @throws MessagingException 68 | */ 69 | Message createInOnlyMessage() throws MessagingException; 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/jaxp/StringSource.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.apache.servicemix.jbi.jaxp; 18 | 19 | import java.io.ByteArrayInputStream; 20 | import java.io.InputStream; 21 | import java.io.Reader; 22 | import java.io.Serializable; 23 | import java.io.StringReader; 24 | import java.io.UnsupportedEncodingException; 25 | 26 | import javax.xml.transform.stream.StreamSource; 27 | 28 | /** 29 | * A helper class which provides a JAXP {@link javax.xml.transform.Source} from a String which can 30 | * be read as many times as required. 31 | * 32 | * @version $Revision: 564607 $ 33 | */ 34 | public class StringSource extends StreamSource implements Serializable { 35 | 36 | private final String text; 37 | 38 | private String encoding = "UTF-8"; 39 | 40 | public StringSource(String text) { 41 | if (text == null) { 42 | throw new NullPointerException("text can not be null"); 43 | } 44 | this.text = text; 45 | } 46 | 47 | public StringSource(String text, String systemId) { 48 | this(text); 49 | setSystemId(systemId); 50 | } 51 | 52 | public StringSource(String text, String systemId, String encoding) { 53 | this.text = text; 54 | this.encoding = encoding; 55 | setSystemId(systemId); 56 | } 57 | 58 | public InputStream getInputStream() { 59 | try { 60 | return new ByteArrayInputStream(text.getBytes(encoding)); 61 | } catch (UnsupportedEncodingException e) { 62 | throw new RuntimeException(e); 63 | } 64 | } 65 | 66 | public Reader getReader() { 67 | return new StringReader(text); 68 | } 69 | 70 | public String toString() { 71 | return "StringSource[" + text + "]"; 72 | } 73 | 74 | public String getText() { 75 | return text; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jbi/marshaler/PojoMarshaler.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.apache.servicemix.jbi.marshaler; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | 23 | /** 24 | * A plugin strategy which marshals an Object into and out of a JBI message. 25 | * This interface is used by the ServiceMixClient to marshal POJOs into and out 26 | * of JBI messages. 27 | * 28 | * @version $Revision: 564607 $ 29 | */ 30 | public interface PojoMarshaler { 31 | 32 | /** 33 | * The key on the message to store the message body which cannot be 34 | * marshaled into or out of XML easily or to provide a cache of the object 35 | * representation of the object. 36 | */ 37 | String BODY = "org.apache.servicemix.body"; 38 | 39 | /** 40 | * Marshals the payload into the normalized message, typically as the 41 | * content property. 42 | * 43 | * @param exchange 44 | * the message exchange in which to marshal 45 | * @param message 46 | * the message in which to marshal 47 | * @param body 48 | * the body of the message as a POJO 49 | */ 50 | void marshal(MessageExchange exchange, NormalizedMessage message, Object body) throws MessagingException; 51 | 52 | /** 53 | * Unmarshals the response out of the normalized message. 54 | * 55 | * @param exchange 56 | * the message exchange, which is an {@link InOut} or 57 | * {@link InOptionalOut} 58 | * @param message 59 | * the output message 60 | * @return the unmarshaled body object, extracted from the message 61 | * @throws MessagingException 62 | */ 63 | Object unmarshal(MessageExchange exchange, NormalizedMessage message) throws MessagingException; 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/store/memory/MemoryStore.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.apache.servicemix.store.memory; 18 | 19 | import java.io.IOException; 20 | import java.util.Map; 21 | import java.util.concurrent.ConcurrentHashMap; 22 | 23 | import org.apache.servicemix.id.IdGenerator; 24 | import org.apache.servicemix.store.base.BaseStore; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | 28 | /** 29 | * A simple memory store implementation based on a simple map. 30 | * This store is neither clusterable, nor persistent, nor transactional. 31 | * 32 | * @author gnodet 33 | */ 34 | public class MemoryStore extends BaseStore { 35 | 36 | private static final Logger LOG = LoggerFactory.getLogger(MemoryStore.class); 37 | 38 | private Map datas = new ConcurrentHashMap(); 39 | 40 | private IdGenerator idGenerator; 41 | 42 | public MemoryStore(IdGenerator idGenerator) { 43 | this.idGenerator = idGenerator; 44 | } 45 | 46 | public boolean hasFeature(String name) { 47 | return false; 48 | } 49 | 50 | public void store(String id, Object data) throws IOException { 51 | LOG.debug("Storing object with id: " + id); 52 | datas.put(id, data); 53 | fireAddedEvent(id,data); 54 | } 55 | 56 | public String store(Object data) throws IOException { 57 | String id = idGenerator.generateId(); 58 | store(id, data); 59 | return id; 60 | } 61 | 62 | public Object load(String id) throws IOException { 63 | LOG.debug("Loading/Removing object with id: " + id); 64 | Object data = datas.remove(id); 65 | fireEvictedEvent(id,data); 66 | return data; 67 | } 68 | 69 | public Object peek(String id) throws IOException { 70 | LOG.debug("Peeking object with id: " + id); 71 | return datas.get(id); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/expression/JAXPXPathExpressionTest.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.apache.servicemix.expression; 18 | 19 | import org.apache.servicemix.jbi.jaxp.SimpleNamespaceContext; 20 | import org.apache.xalan.extensions.XPathFunctionResolverImpl; 21 | 22 | 23 | /** 24 | * @version $Revision: 564607 $ 25 | */ 26 | public class JAXPXPathExpressionTest extends XPathExpressionTest { 27 | 28 | /** 29 | * Note that this test only works on Java 5 30 | * 31 | * @throws Exception 32 | */ 33 | public void testXPathUsingJAXP() throws Exception { 34 | boolean test = false; 35 | 36 | try { 37 | Class.forName("java.lang.annotation.AnnotationTypeMismatchException"); 38 | test = true; 39 | } catch (ClassNotFoundException doNothing) { 40 | // Expected if not java 5 41 | } 42 | 43 | if (test) { 44 | assertExpression(new JAXPStringXPathExpression("/foo/bar/@xyz"), "cheese", ""); 45 | assertExpression(new JAXPStringXPathExpression("$name"), "James", ""); 46 | } 47 | } 48 | 49 | public void testUsingJavaExtensions() throws Exception { 50 | JAXPStringXPathExpression exp = new JAXPStringXPathExpression(); 51 | exp.setXPath("java:org.apache.servicemix.expression.JAXPXPathExpressionTest.func(string(/header/value))"); 52 | SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(); 53 | namespaceContext.add("java", "http://xml.apache.org/xalan/java"); 54 | exp.setNamespaceContext(namespaceContext); 55 | exp.setFunctionResolver(new XPathFunctionResolverImpl()); 56 | assertExpression(exp, "modified12", "
12
"); 57 | } 58 | 59 | public static String func(String s) { 60 | return "modified" + s; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/PropertyExpression.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | 23 | /** 24 | * A simple expression which returns the value of a property on the message. 25 | * 26 | * @version $Revision: 451186 $ 27 | */ 28 | public class PropertyExpression implements Expression { 29 | private String property; 30 | private Object defaultValue; 31 | 32 | public PropertyExpression() { 33 | } 34 | 35 | public PropertyExpression(String property) { 36 | this.property = property; 37 | } 38 | 39 | public PropertyExpression(String property, Object defaultValue) { 40 | this.property = property; 41 | this.defaultValue = defaultValue; 42 | } 43 | 44 | /** 45 | * @return the defaultValue 46 | */ 47 | public Object getDefaultValue() { 48 | return defaultValue; 49 | } 50 | 51 | /** 52 | * @param defaultValue the defaultValue to set 53 | */ 54 | public void setDefaultValue(Object defaultValue) { 55 | this.defaultValue = defaultValue; 56 | } 57 | 58 | /** 59 | * @return the property 60 | */ 61 | public String getProperty() { 62 | return property; 63 | } 64 | 65 | /** 66 | * @param property the property to set 67 | */ 68 | public void setProperty(String property) { 69 | this.property = property; 70 | } 71 | 72 | public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException { 73 | Object answer = message.getProperty(property); 74 | if (answer == null) { 75 | answer = exchange.getProperty(property); 76 | if (answer == null) { 77 | answer = defaultValue; 78 | } 79 | } 80 | return answer; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/store/memory/ConcurrentTimeoutMemoryStoreTest.java: -------------------------------------------------------------------------------- 1 | package org.apache.servicemix.store.memory; 2 | 3 | import org.apache.servicemix.executors.Executor; 4 | import org.apache.servicemix.executors.ExecutorFactory; 5 | import org.apache.servicemix.executors.impl.ExecutorFactoryImpl; 6 | import org.apache.servicemix.id.IdGenerator; 7 | import org.apache.servicemix.store.Store; 8 | import org.junit.Test; 9 | 10 | import java.util.Random; 11 | import java.util.concurrent.CountDownLatch; 12 | import java.util.concurrent.TimeUnit; 13 | 14 | import static org.junit.Assert.assertTrue; 15 | import static org.junit.Assert.fail; 16 | 17 | /** 18 | * Test case to ensure the {@link TimeoutMemoryStore} behaves properly under multi-threaded l 19 | */ 20 | public class ConcurrentTimeoutMemoryStoreTest { 21 | 22 | private static final int NUMBER_OF_EXECUTORS = 5; 23 | private static final int NUMBER_OF_OPERATIONS = 1000; 24 | private static final Random RANDOM = new Random(); 25 | private static final int RANDOMNESS = 5; 26 | 27 | private final ExecutorFactory factory = new ExecutorFactoryImpl(); 28 | private final Store store = new TimeoutMemoryStore(new IdGenerator(), 100); 29 | 30 | @Test 31 | public void testConcurrentLoadAndStore() throws Exception { 32 | final CountDownLatch latch = new CountDownLatch(NUMBER_OF_EXECUTORS * NUMBER_OF_OPERATIONS); 33 | 34 | final Executor executor = factory.createExecutor("concurrent.timemout.memory.store"); 35 | for (int i = 0 ; i < 5 ; i++) { 36 | executor.execute(new RandomAccessExecutable(store, latch)); 37 | } 38 | 39 | assertTrue("We should have processed all operations successfully", latch.await(3, TimeUnit.SECONDS)); 40 | } 41 | 42 | /** 43 | * {@link Runnable} that randomly stores and removes items from a {@link Store} implementation 44 | */ 45 | private class RandomAccessExecutable implements Runnable { 46 | 47 | private final Store store; 48 | private final CountDownLatch latch; 49 | 50 | public RandomAccessExecutable(Store store, CountDownLatch latch) { 51 | super(); 52 | this.store = store; 53 | this.latch = latch; 54 | } 55 | 56 | public void run() { 57 | for (int i = 0 ; i < NUMBER_OF_OPERATIONS ; i++) { 58 | try { 59 | store.store("Item " + RANDOM.nextInt(RANDOMNESS)); 60 | store.load("Item " + RANDOM.nextInt(RANDOMNESS)); 61 | latch.countDown(); 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | fail("Unexception exception caught: " + e); 65 | } 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/jdbc/adapter/StreamJDBCAdapter.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.apache.servicemix.jdbc.adapter; 18 | 19 | import java.io.ByteArrayInputStream; 20 | import java.io.ByteArrayOutputStream; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.sql.PreparedStatement; 24 | import java.sql.ResultSet; 25 | import java.sql.SQLException; 26 | 27 | /** 28 | * This JDBCAdapter inserts and extracts BLOB data using the 29 | * setBinaryStream()/getBinaryStream() operations. 30 | * 31 | * The databases/JDBC drivers that use this adapter are: 32 | *
    33 | *
  • Axion
  • 34 | *
35 | * 36 | * @org.apache.xbean.XBean element="streamJDBCAdapter" 37 | * 38 | * @version $Revision: 1.2 $ 39 | */ 40 | public class StreamJDBCAdapter extends DefaultJDBCAdapter { 41 | 42 | /** 43 | * @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#getBinaryData(java.sql.ResultSet, int) 44 | */ 45 | protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException { 46 | 47 | try { 48 | InputStream is = rs.getBinaryStream(index); 49 | ByteArrayOutputStream os = new ByteArrayOutputStream(1024 * 4); 50 | int ch = is.read(); 51 | while (ch >= 0) { 52 | os.write(ch); 53 | ch = is.read(); 54 | } 55 | is.close(); 56 | os.close(); 57 | return os.toByteArray(); 58 | } catch (IOException e) { 59 | throw (SQLException) new SQLException("Error reading binary parameter: " + index).initCause(e); 60 | } 61 | } 62 | 63 | /** 64 | * @see org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#setBinaryData(java.sql.PreparedStatement, int, byte[]) 65 | */ 66 | protected void setBinaryData(PreparedStatement s, int index, byte[] data) throws SQLException { 67 | s.setBinaryStream(index, new ByteArrayInputStream(data), data.length); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/executors/WorkManagerWrapper.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.apache.servicemix.executors; 18 | 19 | import javax.resource.spi.work.ExecutionContext; 20 | import javax.resource.spi.work.Work; 21 | import javax.resource.spi.work.WorkException; 22 | import javax.resource.spi.work.WorkListener; 23 | import javax.resource.spi.work.WorkManager; 24 | 25 | /** 26 | * This helper class is a simple wrapper around the Executor 27 | * interface to provide a WorkManager. 28 | * 29 | * Note that the implementation is really simplistic 30 | * and all calls will delegate to the execute 31 | * method of the internal Executor. 32 | * 33 | * @author Guillaume Nodet 34 | */ 35 | public class WorkManagerWrapper implements WorkManager { 36 | 37 | private final Executor executor; 38 | 39 | public WorkManagerWrapper(Executor executor) { 40 | this.executor = executor; 41 | } 42 | 43 | public void doWork(Work work) throws WorkException { 44 | executor.execute(work); 45 | } 46 | 47 | public void doWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException { 48 | executor.execute(work); 49 | } 50 | 51 | public void scheduleWork(Work work) throws WorkException { 52 | executor.execute(work); 53 | } 54 | 55 | public void scheduleWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException { 56 | executor.execute(work); 57 | } 58 | 59 | public long startWork(Work work) throws WorkException { 60 | executor.execute(work); 61 | return 0; 62 | } 63 | 64 | public long startWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener) throws WorkException { 65 | executor.execute(work); 66 | return 0; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/jbi/jaxp/FragmentStreamReaderTest.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.apache.servicemix.jbi.jaxp; 18 | 19 | import java.io.ByteArrayInputStream; 20 | import java.io.InputStream; 21 | import java.io.StringWriter; 22 | 23 | import javax.xml.parsers.DocumentBuilderFactory; 24 | import javax.xml.stream.XMLInputFactory; 25 | import javax.xml.stream.XMLStreamReader; 26 | import javax.xml.transform.Transformer; 27 | import javax.xml.transform.TransformerFactory; 28 | import javax.xml.transform.dom.DOMSource; 29 | import javax.xml.transform.stream.StreamResult; 30 | 31 | import org.slf4j.Logger; 32 | import org.slf4j.LoggerFactory; 33 | import org.w3c.dom.Document; 34 | 35 | import junit.framework.TestCase; 36 | 37 | public class FragmentStreamReaderTest extends TestCase { 38 | 39 | private static final Logger LOG = LoggerFactory.getLogger(FragmentStreamReaderTest.class); 40 | 41 | public void testStaxSource() throws Exception { 42 | InputStream is = getClass().getResourceAsStream("test.xml"); 43 | XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(is); 44 | xsr = new ExtendedXMLStreamReader(xsr); 45 | xsr.nextTag(); 46 | LOG.info(xsr.getName().toString()); 47 | xsr.nextTag(); 48 | LOG.info(xsr.getName().toString()); 49 | XMLStreamReader fsr = new FragmentStreamReader(xsr); 50 | StaxSource ss = new StaxSource(fsr); 51 | StringWriter buffer = new StringWriter(); 52 | Transformer transformer = TransformerFactory.newInstance().newTransformer(); 53 | transformer.transform(ss, new StreamResult(buffer)); 54 | LOG.info(buffer.toString()); 55 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 56 | dbf.setNamespaceAware(true); 57 | Document doc = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(buffer.toString().getBytes())); 58 | StringWriter buffer2 = new StringWriter(); 59 | transformer.transform(new DOMSource(doc), new StreamResult(buffer2)); 60 | LOG.info(buffer2.toString()); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/components/util/NumberConverter.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.apache.servicemix.components.util; 18 | 19 | /** 20 | * Column converter for SimpleFlatFileMarshaler that converts string 21 | * representations of numbers. Zero values and blank columns in flat files can 22 | * be converted to empty strings (default setting) 23 | * 24 | * @author Mayrbaeurl 25 | * @since 3.2 26 | */ 27 | public class NumberConverter implements ContentConverter { 28 | 29 | private boolean zeroValueIsNull = true; 30 | 31 | private boolean blankValueIsNull = true; 32 | 33 | // Implementation methods 34 | // ------------------------------------------------------------------------- 35 | public String convertToXml(String contents) { 36 | if (contents != null) { 37 | int number = 0; 38 | if (!StringUtils.isBlank(contents)) { 39 | try { 40 | number = Integer.parseInt(contents); 41 | } catch (NumberFormatException e) { 42 | return contents; 43 | } 44 | } else { 45 | if (this.blankValueIsNull) { 46 | return StringUtils.EMPTY; 47 | } else { 48 | return contents; 49 | } 50 | } 51 | if ((this.zeroValueIsNull) && (number == 0)) { 52 | return StringUtils.EMPTY; 53 | } else { 54 | return String.valueOf(number); 55 | } 56 | } else { 57 | return null; 58 | } 59 | } 60 | 61 | public String convertToFlatFileContent(String contents) { 62 | return contents; 63 | } 64 | 65 | // Properties 66 | // ------------------------------------------------------------------------- 67 | public final void setZeroValueIsNull(boolean zeroValueIsNull) { 68 | this.zeroValueIsNull = zeroValueIsNull; 69 | } 70 | 71 | public final void setBlankValueIsNull(boolean blankValueIsNull) { 72 | this.blankValueIsNull = blankValueIsNull; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/store/memory/MemoryStoreFactory.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.apache.servicemix.store.memory; 18 | 19 | import java.io.IOException; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import org.apache.servicemix.id.IdGenerator; 24 | import org.apache.servicemix.store.Store; 25 | import org.apache.servicemix.store.StoreFactory; 26 | import org.apache.servicemix.store.StoreListener; 27 | import org.apache.servicemix.store.base.BaseStoreFactory; 28 | 29 | /** 30 | * {@link StoreFactory} for creating memory-based {@link Store} implementations 31 | * 32 | * If a timeout has been specified, a {@link TimeoutMemoryStore} will be created, 33 | * otherwise the factory will build a plain {@link MemoryStore} 34 | */ 35 | public class MemoryStoreFactory extends BaseStoreFactory { 36 | 37 | private IdGenerator idGenerator = new IdGenerator(); 38 | private Map stores = new HashMap(); 39 | private long timeout = -1; 40 | 41 | /* (non-Javadoc) 42 | * @see org.apache.servicemix.store.ExchangeStoreFactory#get(java.lang.String) 43 | */ 44 | public synchronized Store open(String name) throws IOException { 45 | MemoryStore store = stores.get(name); 46 | if (store == null) { 47 | if (timeout <= 0) { 48 | store = new MemoryStore(idGenerator); 49 | } else { 50 | store = new TimeoutMemoryStore(idGenerator, timeout); 51 | } 52 | 53 | for(StoreListener listener:storeListeners) { 54 | store.addListener(listener); 55 | } 56 | stores.put(name, store); 57 | } 58 | return store; 59 | } 60 | 61 | /* (non-Javadoc) 62 | * @see org.apache.servicemix.store.ExchangeStoreFactory#release(org.apache.servicemix.store.ExchangeStore) 63 | */ 64 | public synchronized void close(Store store) throws IOException { 65 | stores.remove(store); 66 | } 67 | 68 | public void setTimeout(long timeout) { 69 | this.timeout = timeout; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/XMLBeansXPathExpression.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | import javax.xml.transform.TransformerException; 23 | import javax.xml.transform.sax.SAXResult; 24 | 25 | import org.apache.servicemix.jbi.jaxp.SourceTransformer; 26 | import org.apache.xmlbeans.XmlException; 27 | import org.apache.xmlbeans.XmlObject; 28 | import org.apache.xmlbeans.XmlOptions; 29 | import org.apache.xmlbeans.XmlSaxHandler; 30 | 31 | /** 32 | * An {@link Expression} which evaluates an XPath expression using XMLBeans 33 | * 34 | * @version $Revision: 564374 $ 35 | */ 36 | public class XMLBeansXPathExpression implements Expression { 37 | 38 | private String xpath; 39 | 40 | private XmlOptions options = new XmlOptions(); 41 | 42 | private SourceTransformer transformer = new SourceTransformer(); 43 | 44 | public XMLBeansXPathExpression(String xp) { 45 | this.xpath = xp; 46 | } 47 | 48 | public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException { 49 | try { 50 | XmlSaxHandler handler = XmlObject.Factory.newXmlSaxHandler(); 51 | SAXResult result = new SAXResult(handler.getContentHandler()); 52 | transformer.toResult(message.getContent(), result); 53 | XmlObject object = handler.getObject(); 54 | return evaluateXPath(object, xpath, options); 55 | } catch (TransformerException e) { 56 | throw new MessagingException(e); 57 | } catch (XmlException e) { 58 | throw new MessagingException(e); 59 | } 60 | } 61 | 62 | protected Object evaluateXPath(XmlObject object, String xp, XmlOptions opts) { 63 | XmlObject[] xmlObjects = object.selectPath(xp, opts); 64 | if (xmlObjects.length == 1) { 65 | return xmlObjects[0]; 66 | } 67 | return xmlObjects; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/store/krati/KratiStoreTest.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.apache.servicemix.store.krati; 18 | 19 | import java.io.File; 20 | import junit.framework.TestCase; 21 | import krati.store.DataStore; 22 | 23 | import org.slf4j.LoggerFactory; 24 | 25 | public class KratiStoreTest extends TestCase { 26 | 27 | private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(KratiStoreTest.class); 28 | 29 | private static final long TIMEOUT = 1000L; 30 | private static final String TEST_CACHE_NAME = "TEST_CACHE_NAME"; 31 | private KratiStore store; 32 | private KratiStoreFactory storeFactory; 33 | 34 | DataStore dataStore = null; 35 | 36 | public KratiStoreTest() { 37 | if(storeFactory == null){ 38 | storeFactory = new KratiStoreFactory(); 39 | storeFactory.setStoreDirectory("target/krati-store/"); 40 | storeFactory.setTimeout(TIMEOUT); 41 | } 42 | } 43 | 44 | @Override 45 | protected void setUp() throws Exception { 46 | super.setUp(); 47 | if(store == null){ 48 | store = (KratiStore)storeFactory.open(TEST_CACHE_NAME); 49 | } 50 | } 51 | 52 | @Override 53 | protected void tearDown() throws Exception { 54 | super.tearDown(); 55 | storeFactory.close(store); 56 | } 57 | 58 | public void testStore() throws Exception { 59 | String id = "1"; 60 | String data = "Test data"; 61 | store.store(id,data); 62 | assertEquals(data,store.peek(id)); 63 | assertEquals(data,store.load(id)); 64 | assertEquals(null,store.load(id)); 65 | } 66 | 67 | public void testTimeout() throws Exception { 68 | String id = store.store("Any kind of data..."); 69 | Object data = store.load(id); 70 | assertNotNull(data); 71 | //now store it again and load it after the timeout 72 | store.store(id, data); 73 | synchronized (this) { 74 | wait(TIMEOUT * 2); 75 | } 76 | assertNull("Data should have been removed from store after timeout", store.load(id)); 77 | } 78 | 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/expression/MessageVariableResolver.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.NormalizedMessage; 21 | import javax.xml.namespace.QName; 22 | import javax.xml.xpath.XPathVariableResolver; 23 | 24 | /** 25 | * A variable resolver for XPath expressions which support properties on the messge, exchange as well 26 | * as making system properties and environment properties available. 27 | * 28 | * @version $Revision: 564374 $ 29 | */ 30 | public class MessageVariableResolver implements XPathVariableResolver { 31 | public static final String SYSTEM_PROPERTIES_NAMESPACE = "http://servicemix.org/xml/variables/system-properties"; 32 | public static final String ENVIRONMENT_VARIABLES = "http://servicemix.org/xml/variables/environment-variables"; 33 | 34 | private MessageExchange exchange; 35 | private NormalizedMessage message; 36 | 37 | public MessageExchange getExchange() { 38 | return exchange; 39 | } 40 | 41 | public void setExchange(MessageExchange exchange) { 42 | this.exchange = exchange; 43 | } 44 | 45 | public NormalizedMessage getMessage() { 46 | return message; 47 | } 48 | 49 | public void setMessage(NormalizedMessage message) { 50 | this.message = message; 51 | } 52 | 53 | public Object resolveVariable(QName name) { 54 | // should we use other namespaces maybe? 55 | String uri = name.getNamespaceURI(); 56 | String localPart = name.getLocalPart(); 57 | 58 | Object answer = null; 59 | 60 | if (uri == null || uri.length() == 0) { 61 | answer = message.getProperty(localPart); 62 | if (answer == null) { 63 | answer = exchange.getProperty(localPart); 64 | } 65 | } else if (uri.equals(SYSTEM_PROPERTIES_NAMESPACE)) { 66 | answer = System.getProperty(localPart); 67 | } else if (uri.equals(ENVIRONMENT_VARIABLES)) { 68 | answer = System.getProperty(System.getProperty(localPart)); 69 | } 70 | return answer; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/store/base/BaseStore.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.apache.servicemix.store.base; 18 | 19 | import org.apache.servicemix.store.Store; 20 | import org.apache.servicemix.store.StoreListener; 21 | 22 | import java.io.Serializable; 23 | import java.util.LinkedHashSet; 24 | import java.util.Set; 25 | 26 | /** 27 | * @author: iocanel 28 | */ 29 | public abstract class BaseStore implements Store, Serializable { 30 | 31 | protected final Set storeListeners = new LinkedHashSet(); 32 | 33 | /** 34 | * Notify all registered {@link StoreListener}s that an item has been added. 35 | * @param id 36 | * @param data 37 | */ 38 | public void fireAddedEvent(String id, Object data) { 39 | for(StoreListener listener:storeListeners) { 40 | listener.onAdd(id,data); 41 | } 42 | } 43 | 44 | /** 45 | * Notify all registered {@link StoreListener}s that an item has been removed. 46 | * @param id 47 | * @param data 48 | */ 49 | public void fireRemovedEvent(String id, Object data) { 50 | for(StoreListener listener:storeListeners) { 51 | listener.onRemove(id, data); 52 | } 53 | } 54 | 55 | /** 56 | * Notify all registered {@link StoreListener}s that an item has been evicted. 57 | * @param id 58 | * @param data 59 | */ 60 | public void fireEvictedEvent(String id, Object data) { 61 | for(StoreListener listener:storeListeners) { 62 | listener.onEvict(id, data); 63 | } 64 | } 65 | 66 | /*** 67 | * Registers a {@link StoreListener}. 68 | * @param listener 69 | */ 70 | public void addListener(StoreListener listener) { 71 | storeListeners.add(listener); 72 | } 73 | 74 | /*** 75 | * Unregisters a {@link StoreListener}. 76 | * @param listener 77 | */ 78 | public void removeListener(StoreListener listener) { 79 | storeListeners.remove(listener); 80 | } 81 | 82 | /*** 83 | * Lists all {@link StoreListener}s. 84 | */ 85 | public Set getStoreListeners() { 86 | return storeListeners; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/expression/XPathExpressionTest.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.apache.servicemix.expression; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | 23 | import junit.framework.TestCase; 24 | 25 | import org.apache.servicemix.jbi.jaxp.StringSource; 26 | import org.apache.servicemix.tck.mock.MockMessageExchange; 27 | 28 | /** 29 | * @version $Revision: 564607 $ 30 | */ 31 | public class XPathExpressionTest extends TestCase { 32 | 33 | public void testXPathUsingJaxen() throws Exception { 34 | assertExpression(new JaxenStringXPathExpression("foo/bar"), "cheese", "cheese"); 35 | assertExpression(new JaxenStringXPathExpression("foo/bar/@xyz"), "cheese", ""); 36 | assertExpression(new JaxenStringXPathExpression("$name"), "James", ""); 37 | assertExpression(new JaxenStringXPathExpression("foo/bar/text()"), "cheese", "cheese"); 38 | } 39 | 40 | public void testXPathUsingXMLBeans() throws Exception { 41 | assertExpression(new XMLBeansStringXPathExpression("foo/bar"), "cheese", "cheese"); 42 | assertExpression(new XMLBeansStringXPathExpression("foo/bar/@xyz"), "cheese", ""); 43 | 44 | // These are way too complex for XMLBeans! :) 45 | //assertExpression(new XMLBeansStringXPathExpression("$name"), "James", ""); 46 | //assertExpression(new XMLBeansStringXPathExpression("foo/bar/text()"), "cheese", "cheese"); 47 | } 48 | 49 | protected void assertExpression(Expression expression, String expected, String xml) throws MessagingException { 50 | MessageExchange exchange = new MockMessageExchange(); 51 | NormalizedMessage message = exchange.createMessage(); 52 | message.setProperty("name", "James"); 53 | message.setContent(new StringSource(xml)); 54 | Object value = expression.evaluate(exchange, message); 55 | assertEquals("Expression: " + expression, expected, value); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/components/util/FileExtensionPropertyExpression.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.apache.servicemix.components.util; 18 | 19 | import javax.jbi.messaging.MessageExchange; 20 | import javax.jbi.messaging.MessagingException; 21 | import javax.jbi.messaging.NormalizedMessage; 22 | 23 | import org.apache.servicemix.expression.PropertyExpression; 24 | 25 | /** 26 | * Expression that returns the 'org.apache.servicemix.file.name' property on the 27 | * message added by a file extensions. Existing file extensions are by default 28 | * removed 29 | * 30 | * @author Mayrbaeurl 31 | * @since 3.2 32 | */ 33 | public class FileExtensionPropertyExpression extends PropertyExpression { 34 | 35 | private final String extension; 36 | 37 | private boolean deleteExistingExtension = true; 38 | 39 | public FileExtensionPropertyExpression(String fileExtension) { 40 | super(DefaultFileMarshaler.FILE_NAME_PROPERTY); 41 | 42 | this.extension = fileExtension; 43 | } 44 | 45 | public FileExtensionPropertyExpression(String extension, 46 | boolean deleteExistingExtension) { 47 | super(DefaultFileMarshaler.FILE_NAME_PROPERTY); 48 | 49 | this.extension = extension; 50 | this.deleteExistingExtension = deleteExistingExtension; 51 | } 52 | 53 | // Implementation methods 54 | // ------------------------------------------------------------------------- 55 | public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException { 56 | Object result = super.evaluate(exchange, message); 57 | if ((result != null) && (result instanceof String)) { 58 | return this.removeExtension((String) result) + this.extension; 59 | } else { 60 | return result; 61 | } 62 | } 63 | 64 | private String removeExtension(String fileName) { 65 | String result = fileName; 66 | if (this.deleteExistingExtension && fileName != null && fileName.length() > 1) { 67 | int index = fileName.lastIndexOf('.'); 68 | if (index != -1) { 69 | result = fileName.substring(0, index); 70 | } 71 | } 72 | return result; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/executors/impl/LogThrowableInExecutorTest.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.apache.servicemix.executors.impl; 18 | 19 | import junit.framework.TestCase; 20 | import org.apache.log4j.AppenderSkeleton; 21 | import org.apache.log4j.Logger; 22 | import org.apache.log4j.spi.LoggingEvent; 23 | import org.apache.servicemix.executors.Executor; 24 | import org.apache.servicemix.executors.ExecutorFactory; 25 | 26 | import java.util.concurrent.BlockingQueue; 27 | import java.util.concurrent.LinkedBlockingDeque; 28 | import java.util.concurrent.TimeUnit; 29 | 30 | /** 31 | * Test case to ensure that Executor will always log throwables from the executed Runnable (SM-1847) 32 | */ 33 | public class LogThrowableInExecutorTest extends TestCase { 34 | 35 | private static final String MESSAGE = "I'm a bad Runnable throwing errors at people"; 36 | 37 | public void testThrowableLogged() throws InterruptedException { 38 | final BlockingQueue events = new LinkedBlockingDeque(); 39 | 40 | // unit tests use LOG4J as the backend for SLF4J so add the appender to LOG4J 41 | Logger.getLogger(ExecutorImpl.class).addAppender(new AppenderSkeleton() { 42 | @Override 43 | protected void append(LoggingEvent event) { 44 | events.offer(event); 45 | } 46 | 47 | @Override 48 | public boolean requiresLayout() { 49 | return false; 50 | } 51 | 52 | @Override 53 | public void close() { 54 | //graciously do nothing 55 | } 56 | }); 57 | 58 | ExecutorFactory factory = new ExecutorFactoryImpl(); 59 | Executor executor = factory.createExecutor("test"); 60 | executor.execute(new Runnable() { 61 | public void run() { 62 | throw new Error(MESSAGE); 63 | } 64 | }); 65 | 66 | LoggingEvent event = events.poll(10, TimeUnit.SECONDS); 67 | 68 | 69 | assertNotNull("Should have logged a message", event); 70 | assertTrue("Exception message should have been logged", 71 | event.getThrowableStrRep()[0].contains(MESSAGE)); 72 | 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/apache/servicemix/tck/mock/MockNormalizedMessage.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.apache.servicemix.tck.mock; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | import java.util.Set; 22 | 23 | import javax.activation.DataHandler; 24 | import javax.jbi.messaging.MessagingException; 25 | import javax.jbi.messaging.NormalizedMessage; 26 | import javax.security.auth.Subject; 27 | import javax.xml.transform.Source; 28 | 29 | public class MockNormalizedMessage implements NormalizedMessage { 30 | 31 | private Source content; 32 | private Map properties = new HashMap(); 33 | private Map attachments = new HashMap(); 34 | private Subject securitySubject; 35 | 36 | /** 37 | * @return the content 38 | */ 39 | public Source getContent() { 40 | return this.content; 41 | } 42 | /** 43 | * @param content the content to set 44 | */ 45 | public void setContent(Source content) { 46 | this.content = content; 47 | } 48 | /** 49 | * @return the securitySubject 50 | */ 51 | public Subject getSecuritySubject() { 52 | return securitySubject; 53 | } 54 | /** 55 | * @param securitySubject the securitySubject to set 56 | */ 57 | public void setSecuritySubject(Subject securitySubject) { 58 | this.securitySubject = securitySubject; 59 | } 60 | public void addAttachment(String id, DataHandler data) throws MessagingException { 61 | attachments.put(id, data); 62 | } 63 | public DataHandler getAttachment(String id) { 64 | return attachments.get(id); 65 | } 66 | public Set getAttachmentNames() { 67 | return attachments.keySet(); 68 | } 69 | public Object getProperty(String name) { 70 | return properties.get(name); 71 | } 72 | public Set getPropertyNames() { 73 | return properties.keySet(); 74 | } 75 | public void removeAttachment(String id) throws MessagingException { 76 | attachments.remove(id); 77 | } 78 | public void setProperty(String name, Object value) { 79 | properties.put(name, value); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/test/java/org/apache/servicemix/tck/mock/MockExchangeFactoryTest.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.apache.servicemix.tck.mock; 18 | 19 | import javax.jbi.messaging.InOnly; 20 | import javax.jbi.messaging.InOptionalOut; 21 | import javax.jbi.messaging.InOut; 22 | import javax.jbi.messaging.RobustInOnly; 23 | import junit.framework.TestCase; 24 | 25 | /** 26 | * 27 | * @author iocanel 28 | */ 29 | public class MockExchangeFactoryTest extends TestCase { 30 | 31 | public MockExchangeFactoryTest() { 32 | } 33 | 34 | /** 35 | * Test of createInOnlyExchange method, of class MockExchangeFactory. 36 | */ 37 | public void testCreateInOnlyExchange() throws Exception { 38 | MockExchangeFactory instance = new MockExchangeFactory(); 39 | InOnly exchange = instance.createInOnlyExchange(); 40 | assertNotNull(exchange.getExchangeId()); 41 | assertEquals(exchange.getPattern(), MockExchangeFactory.IN_ONLY); 42 | } 43 | 44 | /** 45 | * Test of createInOptionalOutExchange method, of class MockExchangeFactory. 46 | */ 47 | public void testCreateInOptionalOutExchange() throws Exception { 48 | MockExchangeFactory instance = new MockExchangeFactory(); 49 | InOptionalOut exchange = instance.createInOptionalOutExchange(); 50 | assertNotNull(exchange.getExchangeId()); 51 | assertEquals(exchange.getPattern(), MockExchangeFactory.IN_OPTIONAL_OUT); 52 | } 53 | 54 | /** 55 | * Test of createInOutExchange method, of class MockExchangeFactory. 56 | */ 57 | public void testCreateInOutExchange() throws Exception { 58 | MockExchangeFactory instance = new MockExchangeFactory(); 59 | InOut exchange = instance.createInOutExchange(); 60 | assertNotNull(exchange.getExchangeId()); 61 | assertEquals(exchange.getPattern(), MockExchangeFactory.IN_OUT); 62 | } 63 | 64 | /** 65 | * Test of createRobustInOnlyExchange method, of class MockExchangeFactory. 66 | */ 67 | public void testCreateRobustInOnlyExchange() throws Exception { 68 | MockExchangeFactory instance = new MockExchangeFactory(); 69 | RobustInOnly exchange = instance.createRobustInOnlyExchange(); 70 | assertNotNull(exchange.getExchangeId()); 71 | assertEquals(MockExchangeFactory.ROBUST_IN_ONLY,exchange.getPattern()); 72 | } 73 | } 74 | --------------------------------------------------------------------------------