Repository: nifi Updated Branches: refs/heads/master 42a1ee011 -> 6ee6b5e57
http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java deleted file mode 100644 index ab74ddd..0000000 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.jms.cf; - -import org.apache.nifi.controller.ControllerService; -import org.apache.nifi.processor.Processor; -import org.apache.nifi.util.TestRunner; -import org.apache.nifi.util.TestRunners; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import java.io.File; -import java.lang.reflect.Method; -import java.util.Iterator; -import java.util.ServiceLoader; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -/** - * - */ -public class JMSConnectionFactoryProviderTest { - - private static Logger logger = LoggerFactory.getLogger(JMSConnectionFactoryProviderTest.class); - - @Test - public void validateFullConfigWithUserLib() throws Exception { - TestRunner runner = TestRunners.newTestRunner(mock(Processor.class)); - JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider(); - runner.addControllerService("cfProvider", cfProvider); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI, "myhost:1234"); - - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, - new File("test-lib").getAbsolutePath()); // see README in 'test-lib' dir for more info - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL, - "org.apache.nifi.jms.testcflib.TestConnectionFactory"); - runner.setProperty(cfProvider, "Foo", "foo"); - runner.setProperty(cfProvider, "Bar", "3"); - - runner.enableControllerService(cfProvider); - runner.assertValid(cfProvider); - ConnectionFactory cf = cfProvider.getConnectionFactory(); - assertNotNull(cf); - assertEquals("org.apache.nifi.jms.testcflib.TestConnectionFactory", cf.getClass().getName()); - assertEquals("myhost", this.get("getHost", cf)); - assertEquals(1234, ((Integer) this.get("getPort", cf)).intValue()); - assertEquals("foo", this.get("getFoo", cf)); - assertEquals(3, ((Integer) this.get("getBar", cf)).intValue()); - } - - @Test(expected = AssertionError.class) - public void validateOnConfigureFailsIfCNFonConnectionFactory() throws Exception { - TestRunner runner = TestRunners.newTestRunner(mock(Processor.class)); - JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider(); - runner.addControllerService("cfProvider", cfProvider); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI, "myhost:1234"); - - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, "test-lib"); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL, - "foo.bar.NonExistingConnectionFactory"); - runner.enableControllerService(cfProvider); - } - - @Test - public void validateNotValidForNonExistingLibPath() throws Exception { - TestRunner runner = TestRunners.newTestRunner(mock(Processor.class)); - JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider(); - runner.addControllerService("cfProvider", cfProvider); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI, "myhost:1234"); - - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, "foo"); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL, - "org.apache.nifi.jms.testcflib.TestConnectionFactory"); - runner.assertNotValid(cfProvider); - } - - @Test(expected = AssertionError.class) - public void validateFailsIfURINotHostPortAndNotActiveMQ() throws Exception { - TestRunner runner = TestRunners.newTestRunner(mock(Processor.class)); - JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider(); - runner.addControllerService("cfProvider", cfProvider); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI, "myhost"); - - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, "test-lib"); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL, - "org.apache.nifi.jms.testcflib.TestConnectionFactory"); - runner.enableControllerService(cfProvider); - runner.assertNotValid(cfProvider); - } - - @Test - public void validateNotValidForNonDirectoryPath() throws Exception { - TestRunner runner = TestRunners.newTestRunner(mock(Processor.class)); - JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider(); - runner.addControllerService("cfProvider", cfProvider); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI, "myhost:1234"); - - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, "pom.xml"); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL, - "org.apache.nifi.jms.testcflib.TestConnectionFactory"); - runner.assertNotValid(cfProvider); - } - - @Test(expected = IllegalStateException.class) - public void validateGetConnectionFactoryFailureIfServiceNotConfigured() throws Exception { - new JMSConnectionFactoryProvider().getConnectionFactory(); - } - - /** - * This test simply validates that {@link ConnectionFactory} can be setup by - * pointing to the location of the client libraries at runtime. It uses - * ActiveMQ which is not present at the POM but instead pulled from Maven - * repo using {@link TestUtils#setupActiveMqLibForTesting(boolean)}, which - * implies that for this test to run the computer must be connected to the - * Internet. If computer is not connected to the Internet, this test will - * quietly fail logging a message. - */ - @Test - public void validateFactoryCreationWithActiveMQLibraries() throws Exception { - try { - String libPath = TestUtils.setupActiveMqLibForTesting(true); - - TestRunner runner = TestRunners.newTestRunner(mock(Processor.class)); - JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider(); - runner.addControllerService("cfProvider", cfProvider); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI, - "vm://localhost?broker.persistent=false"); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, libPath); - runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL, - "org.apache.activemq.ActiveMQConnectionFactory"); - runner.enableControllerService(cfProvider); - runner.assertValid(cfProvider); - - Connection connection = cfProvider.getConnectionFactory().createConnection(); - connection.start(); - - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Destination queue = session.createQueue("myqueue"); - MessageProducer producer = session.createProducer(queue); - MessageConsumer consumer = session.createConsumer(queue); - - TextMessage message = session.createTextMessage("Hello"); - producer.send(message); - assertEquals("Hello", ((TextMessage) consumer.receive()).getText()); - connection.stop(); - connection.close(); - } catch (Exception e) { - logger.error("'validateFactoryCreationWithActiveMQLibraries' failed due to ", e); - } - } - - @Test - public void validateServiceIsLocatableViaServiceLoader() { - ServiceLoader<ControllerService> loader = ServiceLoader.<ControllerService> load(ControllerService.class); - Iterator<ControllerService> iter = loader.iterator(); - boolean present = false; - while (iter.hasNext()) { - ControllerService cs = iter.next(); - assertTrue(cs instanceof JMSConnectionFactoryProviderDefinition); - present = true; - } - assertTrue(present); - } - - @SuppressWarnings("unchecked") - private <T> T get(String methodName, ConnectionFactory cf) throws Exception { - Method m = Utils.findMethod(methodName, cf.getClass()); - return (T) m.invoke(cf); - } -} http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/java/org/apache/nifi/jms/cf/TestUtils.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/java/org/apache/nifi/jms/cf/TestUtils.java b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/java/org/apache/nifi/jms/cf/TestUtils.java deleted file mode 100644 index 7d5e636..0000000 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/java/org/apache/nifi/jms/cf/TestUtils.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.jms.cf; - -import java.io.File; -import java.io.FileOutputStream; -import java.net.URL; -import java.nio.channels.Channels; -import java.nio.channels.ReadableByteChannel; - -import org.apache.commons.io.FileUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - */ -class TestUtils { - - static Logger logger = LoggerFactory.getLogger(TestUtils.class); - - static String setupActiveMqLibForTesting(boolean clean) { - String[] urlsStrings = new String[]{ - "http://central.maven.org/maven2/org/apache/activemq/activemq-client/5.13.0/activemq-client-5.13.0.jar", - "http://central.maven.org/maven2/org/apache/activemq/activemq-broker/5.13.0/activemq-broker-5.13.0.jar", - "http://central.maven.org/maven2/org/apache/geronimo/specs/geronimo-j2ee-management_1.0_spec/1.0.1/geronimo-j2ee-management_1.0_spec-1.0.1.jar", - "http://central.maven.org/maven2/org/fusesource/hawtbuf/hawtbuf/1.11/hawtbuf-1.11.jar" }; - - try { - File activeMqLib = new File("target/active-mq-lib"); - if (activeMqLib.exists() && clean) { - FileUtils.deleteDirectory(activeMqLib); - } - activeMqLib.mkdirs(); - for (String urlString : urlsStrings) { - URL url = new URL(urlString); - String path = url.getPath(); - path = path.substring(path.lastIndexOf("/") + 1); - logger.info("Downloading: " + path); - ReadableByteChannel rbc = Channels.newChannel(url.openStream()); - try (FileOutputStream fos = new FileOutputStream(new File(activeMqLib, path))) { - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - } - } - return activeMqLib.getAbsolutePath(); - } catch (Exception e) { - throw new IllegalStateException("Failed to download ActiveMQ libraries.", e); - } - } -} http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/resources/log4j.properties b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/resources/log4j.properties deleted file mode 100644 index ad19977..0000000 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/src/test/resources/log4j.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -log4j.rootCategory=DEBUG, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n - http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/README ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/README b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/README deleted file mode 100644 index 48b9e8a..0000000 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/README +++ /dev/null @@ -1,4 +0,0 @@ -The binary contained in this folder is used for testing and contains only one -class that you can find in 'org.apache.nifi.jms.testcflib' folder. This class -represents test implementation of javax.jms.ConnectionFactory used to validate -that classes are loaded from user defined class path directory. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/org.apache.nifi.jms.testcflib/TestConnectionFactory.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/org.apache.nifi.jms.testcflib/TestConnectionFactory.java b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/org.apache.nifi.jms.testcflib/TestConnectionFactory.java deleted file mode 100644 index 96839c6..0000000 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/org.apache.nifi.jms.testcflib/TestConnectionFactory.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.jms.testcflib; - -import static org.mockito.Mockito.mock; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSContext; -import javax.jms.JMSException; - -public class TestConnectionFactory implements ConnectionFactory { - - private String user; - private String password; - private String foo; - private int bar; - private String host; - - private int port; - - @Override - public Connection createConnection() throws JMSException { - return mock(Connection.class); - } - - @Override - public Connection createConnection(String userName, String password) throws JMSException { - this.user = user; - this.password = password; - return mock(Connection.class); - } - - @Override - public JMSContext createContext() { - return mock(JMSContext.class); - } - - @Override - public JMSContext createContext(String userName, String password) { - this.user = user; - this.password = password; - return mock(JMSContext.class); - } - - @Override - public JMSContext createContext(String userName, String password, int sessionMode) { - this.user = user; - this.password = password; - return mock(JMSContext.class); - } - - @Override - public JMSContext createContext(int sessionMode) { - return mock(JMSContext.class); - } - - public void setFoo(String foo) { - this.foo = foo; - } - - public void setBar(int bar) { - this.bar = bar; - } - - public String getUser() { - return user; - } - - public String getPassword() { - return password; - } - - public String getFoo() { - return foo; - } - - public int getBar() { - return bar; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } -} http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/test_user_lib.jar ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/test_user_lib.jar b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/test_user_lib.jar deleted file mode 100644 index 95f1121..0000000 Binary files a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-cf-service/test-lib/test_user_lib.jar and /dev/null differ http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors-nar/src/main/resources/META-INF/NOTICE ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors-nar/src/main/resources/META-INF/NOTICE b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors-nar/src/main/resources/META-INF/NOTICE index 096a962..f481a0d 100644 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors-nar/src/main/resources/META-INF/NOTICE +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors-nar/src/main/resources/META-INF/NOTICE @@ -15,4 +15,57 @@ The following binary components are provided under the Apache Software License v Apache Commons Lang Copyright 2001-2016 The Apache Software Foundation - + (ASLv2) Apache Commons IO + The following NOTICE information applies: + Apache Commons IO + Copyright 2002-2016 The Apache Software Foundation + + (ASLv2) Apache Commons Logging + The following NOTICE information applies: + Apache Commons Logging + Copyright 2003-2014 The Apache Software Foundation + + (ASLv2) Spring Framework + The following NOTICE information applies: + Spring Framework + Copyright (c) 2002-2015 Pivotal, Inc. + + (ASLv2) Apache Commons Codec + The following NOTICE information applies: + Apache Commons Codec + Copyright 2002-2014 The Apache Software Foundation + + src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java + contains test data from http://aspell.net/test/orig/batch0.tab. + Copyright (C) 2002 Kevin Atkinson ([email protected]) + + =============================================================================== + + The content of package org.apache.commons.codec.language.bm has been translated + from the original php source code available at http://stevemorse.org/phoneticinfo.htm + with permission from the original authors. + Original source copyright: + Copyright (c) 2008 Alexander Beider & Stephen P. Morse. + + (ASLv2) Jackson JSON processor + The following NOTICE information applies: + # Jackson JSON processor + + Jackson is a high-performance, Free/Open Source JSON processing library. + It was originally written by Tatu Saloranta ([email protected]), and has + been in development since 2007. + It is currently developed by a community of developers, as well as supported + commercially by FasterXML.com. + + ## Licensing + + Jackson core and extension components may licensed under different licenses. + To find the details that apply to this artifact see the accompanying LICENSE file. + For more information, including possible other licensing options, contact + FasterXML.com (http://fasterxml.com). + + ## Credits + + A list of contributors may be found from CREDITS file, which is included + in some artifacts (usually source distributions); but is always available + from the source code management (SCM) system project uses. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/pom.xml b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/pom.xml index a4623a1..aac2606 100644 --- a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/pom.xml +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/pom.xml @@ -21,6 +21,7 @@ <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-ssl-context-service-api</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.nifi</groupId> @@ -28,6 +29,10 @@ </dependency> <dependency> <groupId>org.apache.nifi</groupId> + <artifactId>nifi-processor-utils</artifactId> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> <artifactId>nifi-jms-cf-service</artifactId> <scope>provided</scope> <version>1.5.0-SNAPSHOT</version> @@ -60,6 +65,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.17</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-mock</artifactId> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProvider.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProvider.java b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProvider.java new file mode 100644 index 0000000..85d5ffb --- /dev/null +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProvider.java @@ -0,0 +1,352 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.jms.cf; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map.Entry; + +import javax.net.ssl.SSLContext; +import java.io.File; + +import javax.jms.ConnectionFactory; + +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.components.Validator; +import org.apache.nifi.annotation.behavior.DynamicProperty; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.SeeAlso; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnDisabled; +import org.apache.nifi.annotation.lifecycle.OnEnabled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.controller.AbstractControllerService; +import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.ssl.SSLContextService; +import org.apache.nifi.ssl.SSLContextService.ClientAuth; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Provides a factory service that creates and initializes + * {@link ConnectionFactory} specific to the third party JMS system. + * <p> + * It accomplishes it by adjusting current classpath by adding to it the + * additional resources (i.e., JMS client libraries) provided by the user via + * {@link JMSConnectionFactoryProviderDefinition#CLIENT_LIB_DIR_PATH}, allowing + * it then to create an instance of the target {@link ConnectionFactory} based + * on the provided + * {@link JMSConnectionFactoryProviderDefinition#CONNECTION_FACTORY_IMPL} which + * can be than access via {@link #getConnectionFactory()} method. + * </p> + */ +@Tags({"jms", "messaging", "integration", "queue", "topic", "publish", "subscribe"}) +@CapabilityDescription("Provides a generic service to create vendor specific javax.jms.ConnectionFactory implementations. " + + "ConnectionFactory can be served once this service is configured successfully") +@DynamicProperty(name = "The name of a Connection Factory configuration property.", value = "The value of a given Connection Factory configuration property.", + description = "The properties that are set following Java Beans convention where a property name is derived from the 'set*' method of the vendor " + + "specific ConnectionFactory's implementation. For example, 'com.ibm.mq.jms.MQConnectionFactory.setChannel(String)' would imply 'channel' " + + "property and 'com.ibm.mq.jms.MQConnectionFactory.setTransportType(int)' would imply 'transportType' property.") +@SeeAlso(classNames = {"org.apache.nifi.jms.processors.ConsumeJMS", "org.apache.nifi.jms.processors.PublishJMS"}) +public class JMSConnectionFactoryProvider extends AbstractControllerService implements JMSConnectionFactoryProviderDefinition { + + private final Logger logger = LoggerFactory.getLogger(JMSConnectionFactoryProvider.class); + + private static final List<PropertyDescriptor> PROPERTY_DESCRIPTORS; + + private volatile boolean configured; + + private volatile ConnectionFactory connectionFactory; + + static final String BROKER = "broker"; + static final String CF_IMPL = "cf"; + static final String CF_LIB = "cflib"; + + public static final PropertyDescriptor CONNECTION_FACTORY_IMPL = new PropertyDescriptor.Builder() + .name(CF_IMPL) + .displayName("MQ ConnectionFactory Implementation") + .description("A fully qualified name of the JMS ConnectionFactory implementation " + + "class (i.e., org.apache.activemq.ActiveMQConnectionFactory)") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .required(true) + .expressionLanguageSupported(true) + .build(); + public static final PropertyDescriptor CLIENT_LIB_DIR_PATH = new PropertyDescriptor.Builder() + .name(CF_LIB) + .displayName("MQ Client Libraries path (i.e., /usr/jms/lib)") + .description("Path to the directory with additional resources (i.e., JARs, configuration files etc.) to be added " + + "to the classpath. Such resources typically represent target MQ client libraries for the " + + "ConnectionFactory implementation.") + .addValidator(new ClientLibValidator()) + .required(true) + .expressionLanguageSupported(true) + .build(); + + // ConnectionFactory specific properties + public static final PropertyDescriptor BROKER_URI = new PropertyDescriptor.Builder() + .name(BROKER) + .displayName("Broker URI") + .description("URI pointing to the network location of the JMS Message broker. For example, " + + "'tcp://myhost:61616' for ActiveMQ or 'myhost:1414' for IBM MQ") + .addValidator(new NonEmptyBrokerURIValidator()) + .required(true) + .expressionLanguageSupported(true) + .build(); + + public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() + .name("SSL Context Service") + .description("The SSL Context Service used to provide client certificate information for TLS/SSL connections.") + .required(false) + .identifiesControllerService(SSLContextService.class) + .build(); + + static { + PROPERTY_DESCRIPTORS = Collections.unmodifiableList(Arrays.asList(CONNECTION_FACTORY_IMPL, CLIENT_LIB_DIR_PATH, BROKER_URI, SSL_CONTEXT_SERVICE)); + } + + @Override + protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { + return PROPERTY_DESCRIPTORS; + } + + @Override + protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { + return new PropertyDescriptor.Builder() + .description("Specifies the value for '" + propertyDescriptorName + + "' property to be set on the provided ConnectionFactory implementation.") + .name(propertyDescriptorName).addValidator(StandardValidators.NON_EMPTY_VALIDATOR).dynamic(true) + .build(); + } + + /** + * + * @return new instance of {@link ConnectionFactory} + */ + @Override + public ConnectionFactory getConnectionFactory() { + if (this.configured) { + return this.connectionFactory; + } + throw new IllegalStateException("ConnectionFactory can not be obtained unless " + + "this ControllerService is configured. See onConfigure(ConfigurationContext) method."); + } + + @OnEnabled + public void enable(ConfigurationContext context) throws InitializationException { + try { + if (!this.configured) { + if (logger.isInfoEnabled()) { + logger.info("Configuring " + this.getClass().getSimpleName() + " for '" + + context.getProperty(CONNECTION_FACTORY_IMPL).evaluateAttributeExpressions().getValue() + "' to be connected to '" + + BROKER_URI + "'"); + } + // will load user provided libraries/resources on the classpath + Utils.addResourcesToClasspath(context.getProperty(CLIENT_LIB_DIR_PATH).evaluateAttributeExpressions().getValue()); + + this.createConnectionFactoryInstance(context); + + this.setConnectionFactoryProperties(context); + } + this.configured = true; + } catch (Exception e) { + logger.error("Failed to configure " + this.getClass().getSimpleName(), e); + this.configured = false; + throw new IllegalStateException(e); + } + } + + @OnDisabled + public void disable() { + this.connectionFactory = null; + this.configured = false; + } + + /** + * This operation follows standard bean convention by matching property name + * to its corresponding 'setter' method. Once the method was located it is + * invoked to set the corresponding property to a value provided by during + * service configuration. For example, 'channel' property will correspond to + * 'setChannel(..) method and 'queueManager' property will correspond to + * setQueueManager(..) method with a single argument. + * + * There are also few adjustments to accommodate well known brokers. For + * example ActiveMQ ConnectionFactory accepts address of the Message Broker + * in a form of URL while IBMs in the form of host/port pair (more common). + * So this method will use value retrieved from the 'BROKER_URI' static + * property 'as is' if ConnectionFactory implementation is coming from + * ActiveMQ and for all others (for now) the 'BROKER_URI' value will be + * split on ':' and the resulting pair will be used to execute + * setHostName(..) and setPort(..) methods on the provided + * ConnectionFactory. This may need to be maintained and adjusted to + * accommodate other implementation of ConnectionFactory, but only for + * URL/Host/Port issue. All other properties are set as dynamic properties + * where user essentially provides both property name and value, The bean + * convention is also explained in user manual for this component with links + * pointing to documentation of various ConnectionFactories. + * + * @see #setProperty(String, String) method + */ + private void setConnectionFactoryProperties(ConfigurationContext context) { + for (final Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { + PropertyDescriptor descriptor = entry.getKey(); + String propertyName = descriptor.getName(); + if (descriptor.isDynamic()) { + this.setProperty(propertyName, entry.getValue()); + } else { + if (propertyName.equals(BROKER)) { + String brokerValue = context.getProperty(descriptor).evaluateAttributeExpressions().getValue(); + if (context.getProperty(CONNECTION_FACTORY_IMPL).evaluateAttributeExpressions().getValue().startsWith("org.apache.activemq")) { + this.setProperty("brokerURL", brokerValue); + } else { + String[] hostPort = brokerValue.split(":"); + if (hostPort.length == 2) { + this.setProperty("hostName", hostPort[0]); + this.setProperty("port", hostPort[1]); + } else if (hostPort.length != 2) { + this.setProperty("serverUrl", brokerValue); // for tibco + } else { + throw new IllegalArgumentException("Failed to parse broker url: " + brokerValue); + } + } + SSLContextService sc = context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class); + if (sc != null) { + SSLContext ssl = sc.createSSLContext(ClientAuth.NONE); + this.setProperty("sSLSocketFactory", ssl.getSocketFactory()); + } + } // ignore 'else', since it's the only non-dynamic property that is relevant to CF configuration + } + } + } + + /** + * Sets corresponding {@link ConnectionFactory}'s property to a + * 'propertyValue' by invoking a 'setter' method that corresponds to + * 'propertyName'. For example, 'channel' property will correspond to + * 'setChannel(..) method and 'queueManager' property will correspond to + * setQueueManager(..) method with a single argument. + * + * NOTE: There is a limited type conversion to accommodate property value + * types since all NiFi configuration properties comes as String. It is + * accomplished by checking the argument type of the method and executing + * its corresponding conversion to target primitive (e.g., value 'true' will + * go thru Boolean.parseBoolean(propertyValue) if method argument is of type + * boolean). None-primitive values are not supported at the moment and will + * result in {@link IllegalArgumentException}. It is OK though since based + * on analysis of several ConnectionFactory implementation the all seem to + * follow bean convention and all their properties using Java primitives as + * arguments. + */ + private void setProperty(String propertyName, Object propertyValue) { + String methodName = this.toMethodName(propertyName); + Method method = Utils.findMethod(methodName, this.connectionFactory.getClass()); + if (method != null) { + try { + Class<?> returnType = method.getParameterTypes()[0]; + if (String.class.isAssignableFrom(returnType)) { + method.invoke(this.connectionFactory, propertyValue); + } else if (int.class.isAssignableFrom(returnType)) { + method.invoke(this.connectionFactory, Integer.parseInt((String) propertyValue)); + } else if (long.class.isAssignableFrom(returnType)) { + method.invoke(this.connectionFactory, Long.parseLong((String) propertyValue)); + } else if (boolean.class.isAssignableFrom(returnType)) { + method.invoke(this.connectionFactory, Boolean.parseBoolean((String) propertyValue)); + } else { + method.invoke(this.connectionFactory, propertyValue); + } + } catch (Exception e) { + throw new IllegalStateException("Failed to set property " + propertyName, e); + } + } else if (propertyName.equals("hostName")) { + this.setProperty("host", propertyValue); // try 'host' as another common convention. + } + } + + /** + * Creates an instance of the {@link ConnectionFactory} from the provided + * 'CONNECTION_FACTORY_IMPL'. + */ + private void createConnectionFactoryInstance(ConfigurationContext context) { + String connectionFactoryImplName = context.getProperty(CONNECTION_FACTORY_IMPL).evaluateAttributeExpressions().getValue(); + this.connectionFactory = Utils.newDefaultInstance(connectionFactoryImplName); + } + + /** + * Will convert propertyName to a method name following bean convention. For + * example, 'channel' property will correspond to 'setChannel method and + * 'queueManager' property will correspond to setQueueManager method name + */ + private String toMethodName(String propertyName) { + char c[] = propertyName.toCharArray(); + c[0] = Character.toUpperCase(c[0]); + return "set" + new String(c); + } + + /** + * {@link Validator} that ensures that brokerURI's length > 0 after EL + * evaluation + */ + static class NonEmptyBrokerURIValidator implements Validator { + + @Override + public ValidationResult validate(String subject, String input, ValidationContext context) { + String value = input; + if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) { + value = context.getProperty(BROKER_URI).evaluateAttributeExpressions().getValue(); + } + return StandardValidators.NON_EMPTY_VALIDATOR.validate(subject, value, context); + } + } + + /** + * + */ + static class ClientLibValidator implements Validator { + + @Override + public ValidationResult validate(String subject, String input, ValidationContext context) { + String libDirPath = context.getProperty(CLIENT_LIB_DIR_PATH).evaluateAttributeExpressions().getValue(); + StringBuilder invalidationMessageBuilder = new StringBuilder(); + if (libDirPath != null) { + File file = new File(libDirPath); + if (!file.isDirectory()) { + invalidationMessageBuilder + .append("MQ Client library directory path must point to a directory. Was '") + .append(file.getAbsolutePath()) + .append("'."); + } + } else { + invalidationMessageBuilder.append("'MQ Client Libraries path' must be provided. \n"); + } + String invalidationMessage = invalidationMessageBuilder.toString(); + ValidationResult vResult; + if (invalidationMessage.length() == 0) { + vResult = new ValidationResult.Builder().subject(subject).input(input) + .explanation("Client lib path is valid and points to a directory").valid(true).build(); + } else { + vResult = new ValidationResult.Builder().subject(subject).input(input) + .explanation("Client lib path is invalid. " + invalidationMessage) + .valid(false).build(); + } + return vResult; + } + } +} http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/Utils.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/Utils.java b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/Utils.java new file mode 100644 index 0000000..cd191c3 --- /dev/null +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/Utils.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.jms.cf; + +import java.io.File; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + */ +public final class Utils { + + private static final Logger logger = LoggerFactory.getLogger(Utils.class); + + /** + * Creates new instance of the class specified by 'className' by first + * loading it using thread context class loader and then executing default + * constructor. + */ + @SuppressWarnings("unchecked") + static <T> T newDefaultInstance(String className) { + try { + Class<T> clazz = (Class<T>) Class.forName(className, false, Thread.currentThread().getContextClassLoader()); + return clazz.newInstance(); + } catch (Exception e) { + throw new IllegalStateException("Failed to load and/or instantiate class '" + className + "'", e); + } + } + + /** + * Finds a method by name on the target class. If more then one method + * present it will return the first one encountered. + * + * @param name method name + * @param targetClass instance of target class + * @return instance of {@link Method} + */ + public static Method findMethod(String name, Class<?> targetClass) { + Class<?> searchType = targetClass; + while (searchType != null) { + Method[] methods = (searchType.isInterface() ? searchType.getMethods() : searchType.getDeclaredMethods()); + for (Method method : methods) { + if (name.equals(method.getName())) { + return method; + } + } + searchType = searchType.getSuperclass(); + } + return null; + } + + /** + * Adds content of the directory specified with 'path' to the classpath. It + * does so by creating a new instance of the {@link URLClassLoader} using + * {@link URL}s created from listing the contents of the directory denoted + * by 'path' and setting it as thread context class loader. + */ + static void addResourcesToClasspath(String path) { + if (logger.isDebugEnabled()) { + logger.debug("Adding additional resources from '" + path + "' to the classpath."); + } + if (path == null) { + throw new IllegalArgumentException("'path' must not be null"); + } + File libraryDir = new File(path); + if (libraryDir.exists() && libraryDir.isDirectory()) { + String[] cpResourceNames = libraryDir.list(); + URL[] urls = new URL[cpResourceNames.length]; + try { + for (int i = 0; i < urls.length; i++) { + urls[i] = new File(libraryDir, cpResourceNames[i]).toURI().toURL(); + if (logger.isDebugEnabled()) { + logger.debug("Identifying additional resource to the classpath: " + urls[i]); + } + } + } catch (Exception e) { + throw new IllegalStateException( + "Failed to parse user libraries from '" + libraryDir.getAbsolutePath() + "'", e); + } + + URLClassLoader cl = new URLClassLoader(urls, Utils.class.getClassLoader()); + Thread.currentThread().setContextClassLoader(cl); + } else { + throw new IllegalArgumentException("Path '" + libraryDir.getAbsolutePath() + + "' is not valid because it doesn't exist or does not point to a directory."); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService new file mode 100644 index 0000000..f191675 --- /dev/null +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService @@ -0,0 +1,15 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +org.apache.nifi.jms.cf.JMSConnectionFactoryProvider http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/resources/docs/org.apache.nifi.jms.cf.JMSConnectionFactoryProvider/additionalDetails.html ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/resources/docs/org.apache.nifi.jms.cf.JMSConnectionFactoryProvider/additionalDetails.html b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/resources/docs/org.apache.nifi.jms.cf.JMSConnectionFactoryProvider/additionalDetails.html new file mode 100644 index 0000000..d1e1325 --- /dev/null +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/resources/docs/org.apache.nifi.jms.cf.JMSConnectionFactoryProvider/additionalDetails.html @@ -0,0 +1,56 @@ +<!DOCTYPE html> +<html lang="en"> + <!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> + <head> + <meta charset="utf-8" /> + <title>JMSConnectionFactoryProvider</title> + <link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css" /> + </head> + + <body> + <h2>Description:</h2> + <p> + This ControllerService serves as a general factory service to serving vendor specific + instances of the <i>javax.jms.ConnectionFactory</i>. It does so by allowing user to + configure vendor specific properties as well as point to the location of the vendor + provided JMS client libraries so the correct implementation of the <i>javax.jms.ConnectionFactory</i> + can be found, loaded, instantiated and served to the dependent Processors (see PublishJMS, ConsumeJMS). + </p> + <p> + To accommodate variety of JMS vendors and their implementation of the <i>ConnectionFactory</i> + this ControllerService exposes only 3 static configuration properties that are common across many implementations + of the <i>ConnectionFactory</i>. The rest of the configuration properties are set following + <a href="http://docstore.mik.ua/orelly/java-ent/jnut/ch06_02.htm">Java Beans</a> convention (see below). + </p> + <p> + The 3 static configuration properties are: + <ul> + <li><b>MQ ConnectionFactory Implementation</b> - A fully qualified name of the JMS ConnectionFactory implementation + class (i.e., org.apache.activemq.ActiveMQConnectionFactory)</li> + <li><b>MQ Client Libraries path</b> - Path to the directory with additional resources (i.e., JARs, configuration files etc.) to be added + to the classpath. Such resources typically represent target MQ client libraries for the ConnectionFactory + implementation. It is optional if you are using Apache ActiveMQ since its libraries are distributed with this component.</li> + <li><b>Broker URI</b> - URI pointing to the network location of the JMS Message broker. For example, 'tcp://myhost:61616' for ActiveMQ or simply 'myhost:1414'.</li> + </ul> + The rest of the properties are set as Dynamic Properties following <a href="http://docstore.mik.ua/orelly/java-ent/jnut/ch06_02.htm">Java Beans</a> + convention where a property name is derived from the <i>set*</i> method of the vendor specific ConnectionFactory's implementation. + For example, <i>com.ibm.mq.jms.MQConnectionFactory.setChannel(String)</i> would imply 'channel' property and + <i>com.ibm.mq.jms.MQConnectionFactory.setTransportType(int)</i> would imply 'transportType' property. + For the list of available properties please consult vendor provided documentation. Here is an example for + <a href="https://www-01.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.javadoc.doc/WMQJMSClasses/com/ibm/mq/jms/MQQueueConnectionFactory.html">IBM's com.ibm.mq.jms.MQConnectionFactory</a> + </p> + </body> +</html> http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java new file mode 100644 index 0000000..9ddfb3f --- /dev/null +++ b/nifi-nar-bundles/nifi-jms-bundle/nifi-jms-processors/src/test/java/org/apache/nifi/jms/cf/JMSConnectionFactoryProviderTest.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.jms.cf; + +import org.apache.nifi.processor.Processor; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.mockito.Mockito.mock; + +/** + * + */ +public class JMSConnectionFactoryProviderTest { + + private static Logger logger = LoggerFactory.getLogger(JMSConnectionFactoryProviderTest.class); + + @Test + public void validateNotValidForNonExistingLibPath() throws Exception { + TestRunner runner = TestRunners.newTestRunner(mock(Processor.class)); + JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider(); + runner.addControllerService("cfProvider", cfProvider); + runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI, "myhost:1234"); + + runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, "foo"); + runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL, + "org.apache.nifi.jms.testcflib.TestConnectionFactory"); + runner.assertNotValid(cfProvider); + } + + @Test + public void validateNotValidForNonDirectoryPath() throws Exception { + TestRunner runner = TestRunners.newTestRunner(mock(Processor.class)); + JMSConnectionFactoryProvider cfProvider = new JMSConnectionFactoryProvider(); + runner.addControllerService("cfProvider", cfProvider); + runner.setProperty(cfProvider, JMSConnectionFactoryProvider.BROKER_URI, "myhost:1234"); + + runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CLIENT_LIB_DIR_PATH, "pom.xml"); + runner.setProperty(cfProvider, JMSConnectionFactoryProvider.CONNECTION_FACTORY_IMPL, + "org.apache.nifi.jms.testcflib.TestConnectionFactory"); + runner.assertNotValid(cfProvider); + } + + @Test(expected = IllegalStateException.class) + public void validateGetConnectionFactoryFailureIfServiceNotConfigured() throws Exception { + new JMSConnectionFactoryProvider().getConnectionFactory(); + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java index 6c09ef5..5f17156 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java @@ -107,8 +107,7 @@ import java.util.regex.Pattern; @WritesAttribute(attribute = "http.headers.XXX", description = "Each of the HTTP Headers that is received in the request will be added as an " + "attribute, prefixed with \"http.headers.\" For example, if the request contains an HTTP Header named \"x-my-header\", then the value " + "will be added to an attribute named \"http.headers.x-my-header\"")}) -@SeeAlso(value = {HandleHttpResponse.class}, - classNames = {"org.apache.nifi.http.StandardHttpContextMap", "org.apache.nifi.ssl.RestrictedStandardSSLContextService"}) +@SeeAlso(value = {HandleHttpResponse.class}) public class HandleHttpRequest extends AbstractProcessor { private static final Pattern URL_QUERY_PARAM_DELIMITER = Pattern.compile("&"); http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java index a5bdd0e..ca3a1db 100644 --- a/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java +++ b/nifi-nar-bundles/nifi-standard-services/nifi-hbase_1_1_2-client-service-bundle/nifi-hbase_1_1_2-client-service/src/main/java/org/apache/nifi/hbase/HBase_1_1_2_ClientMapCacheService.java @@ -46,7 +46,7 @@ import org.apache.nifi.hbase.put.PutColumn; import org.apache.nifi.processor.util.StandardValidators; @Tags({"distributed", "cache", "state", "map", "cluster","hbase"}) -@SeeAlso(classNames = {"org.apache.nifi.distributed.cache.server.map.DistributedMapCacheClient", "org.apache.nifi.hbase.HBase_1_1_2_ClientService"}) +@SeeAlso(classNames = {"org.apache.nifi.hbase.HBase_1_1_2_ClientService"}) @CapabilityDescription("Provides the ability to use an HBase table as a cache, in place of a DistributedMapCache." + " Uses a HBase_1_1_2_ClientService controller to communicate with HBase.") http://git-wip-us.apache.org/repos/asf/nifi/blob/6ee6b5e5/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index ac52457..bc92bcd 100644 --- a/pom.xml +++ b/pom.xml @@ -1189,6 +1189,17 @@ </dependency> <dependency> <groupId>org.apache.nifi</groupId> + <artifactId>nifi-couchbase-services-api-nar</artifactId> + <version>1.5.0-SNAPSHOT</version> + <type>nar</type> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-couchbase-services-api</artifactId> + <version>1.5.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> <artifactId>nifi-riemann-nar</artifactId> <version>1.5.0-SNAPSHOT</version> <type>nar</type>
