Repository: cayenne Updated Branches: refs/heads/master d8a944b0b -> 750d3d551
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-jms/src/main/java/org/apache/cayenne/event/JMSModule.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-jms/src/main/java/org/apache/cayenne/event/JMSModule.java b/eventbridges/cayenne-jms/src/main/java/org/apache/cayenne/event/JMSModule.java deleted file mode 100644 index b532bc5..0000000 --- a/eventbridges/cayenne-jms/src/main/java/org/apache/cayenne/event/JMSModule.java +++ /dev/null @@ -1,54 +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.cayenne.event; - -import org.apache.cayenne.di.Binder; -import org.apache.cayenne.di.MapBuilder; -import org.apache.cayenne.di.Module; - -/** - * @since 4.0 - */ -public class JMSModule implements Module { - - /** - * A DI container key for the Map<String, String> storing - * {@link org.apache.cayenne.event.JMSBridge} properties - * - * @since 4.0 - */ - public static final String JMS_BRIDGE_PROPERTIES_MAP = "cayenne.server.jms_bridge"; - - public static void contributeTopicConnectionFactory(Binder binder, String factory) { - contributeProperties(binder).put(JMSBridge.TOPIC_CONNECTION_FACTORY_PROPERTY, factory); - } - - private static MapBuilder<String> contributeProperties(Binder binder) { - return binder.bindMap(String.class, JMS_BRIDGE_PROPERTIES_MAP); - } - - @Override - public void configure(Binder binder) { - // init properties' defaults - contributeTopicConnectionFactory(binder, JMSBridge.TOPIC_CONNECTION_FACTORY_DEFAULT); - - binder.bind(EventBridge.class).toProvider(JMSBridgeProvider.class); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-jms/src/main/java/org/apache/cayenne/event/JMSServerModuleProvider.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-jms/src/main/java/org/apache/cayenne/event/JMSServerModuleProvider.java b/eventbridges/cayenne-jms/src/main/java/org/apache/cayenne/event/JMSServerModuleProvider.java deleted file mode 100644 index 6979d21..0000000 --- a/eventbridges/cayenne-jms/src/main/java/org/apache/cayenne/event/JMSServerModuleProvider.java +++ /dev/null @@ -1,50 +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.cayenne.event; - -import java.util.Collection; -import java.util.Collections; - -import org.apache.cayenne.configuration.server.CayenneServerModuleProvider; -import org.apache.cayenne.configuration.server.ServerModule; -import org.apache.cayenne.di.Module; - -/** - * @since 4.0 - */ -public class JMSServerModuleProvider implements CayenneServerModuleProvider { - - @Override - public Module module() { - return new JMSModule(); - } - - @Override - public Class<? extends Module> moduleType() { - return JMSModule.class; - } - - @SuppressWarnings("unchecked") - @Override - public Collection<Class<? extends Module>> overrides() { - Collection modules = Collections.singletonList(ServerModule.class); - return modules; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-jms/src/main/resources/META-INF/services/org.apache.cayenne.configuration.server.CayenneServerModuleProvider ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-jms/src/main/resources/META-INF/services/org.apache.cayenne.configuration.server.CayenneServerModuleProvider b/eventbridges/cayenne-jms/src/main/resources/META-INF/services/org.apache.cayenne.configuration.server.CayenneServerModuleProvider deleted file mode 100644 index 7c54e3f..0000000 --- a/eventbridges/cayenne-jms/src/main/resources/META-INF/services/org.apache.cayenne.configuration.server.CayenneServerModuleProvider +++ /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. -################################################################## - -org.apache.cayenne.event.JMSServerModuleProvider \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/CayenneJMSModuleProviderTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/CayenneJMSModuleProviderTest.java b/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/CayenneJMSModuleProviderTest.java deleted file mode 100644 index 3b3e87a..0000000 --- a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/CayenneJMSModuleProviderTest.java +++ /dev/null @@ -1,36 +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.cayenne.event; - -import org.apache.cayenne.configuration.server.CayenneServerModuleProvider; -import org.apache.cayenne.unit.util.ModuleProviderChecker; -import org.junit.Test; - -/** - * @since 4.0 - */ -public class CayenneJMSModuleProviderTest { - - @Test - public void testAutoLoadable() { - ModuleProviderChecker.testProviderPresent(JMSServerModuleProvider.class, CayenneServerModuleProvider.class); - } - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeFactoryTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeFactoryTest.java b/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeFactoryTest.java deleted file mode 100644 index 1e50145..0000000 --- a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeFactoryTest.java +++ /dev/null @@ -1,77 +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.cayenne.event; - -import org.junit.Test; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -public class JMSBridgeFactoryTest { - - protected Collection<EventSubject> subjects = Collections.singleton(new EventSubject("test")); - protected String externalSubject = "subject"; - - @Test - public void testCreateEventBridge() throws Exception { - EventBridge bridge = new JMSBridgeFactory().createEventBridge( - subjects, - externalSubject, - Collections.<String, String>emptyMap()); - - assertNotNull(bridge); - assertTrue(bridge instanceof JMSBridge); - assertEquals(subjects, bridge.getLocalSubjects()); - assertEquals(externalSubject, bridge.getExternalSubject()); - } - - @Test - public void testUseProperties() throws Exception { - JMSBridgeFactory bridgeFactory = new JMSBridgeFactory(); - - Map<String, String> properties = new HashMap<>(); - properties.put(JMSBridge.TOPIC_CONNECTION_FACTORY_PROPERTY, JMSBridgeProviderTest.TOPIC_CONNECTION_FACTORY_TEST); - - JMSBridge bridge = (JMSBridge) bridgeFactory.createEventBridge( - subjects, - externalSubject, - properties); - - assertEquals(bridge.getTopicConnectionFactoryName(), JMSBridgeProviderTest.TOPIC_CONNECTION_FACTORY_TEST); - } - - @Test - public void testUseDefaultProperties() throws Exception { - JMSBridgeFactory bridgeFactory = new JMSBridgeFactory(); - JMSBridge bridge = (JMSBridge) bridgeFactory.createEventBridge( - subjects, - externalSubject, - Collections.<String, String>emptyMap()); - - assertEquals(bridge.getTopicConnectionFactoryName(), JMSBridge.TOPIC_CONNECTION_FACTORY_DEFAULT); - } - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java b/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java deleted file mode 100644 index 83404eb..0000000 --- a/eventbridges/cayenne-jms/src/test/java/org/apache/cayenne/event/JMSBridgeProviderTest.java +++ /dev/null @@ -1,87 +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.cayenne.event; - -import org.apache.cayenne.access.DataDomain; -import org.apache.cayenne.configuration.Constants; -import org.apache.cayenne.configuration.DefaultRuntimeProperties; -import org.apache.cayenne.configuration.RuntimeProperties; -import org.apache.cayenne.di.Binder; -import org.apache.cayenne.di.DIBootstrap; -import org.apache.cayenne.di.Injector; -import org.apache.cayenne.di.Module; -import org.apache.cayenne.log.Slf4jJdbcEventLogger; -import org.apache.cayenne.log.JdbcEventLogger; -import org.apache.cayenne.tx.DefaultTransactionFactory; -import org.apache.cayenne.tx.DefaultTransactionManager; -import org.apache.cayenne.tx.TransactionFactory; -import org.apache.cayenne.tx.TransactionManager; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -public class JMSBridgeProviderTest { - - private final DataDomain DOMAIN = new DataDomain("test"); - private final EventManager EVENT_MANAGER = new DefaultEventManager(); - protected static final String TOPIC_CONNECTION_FACTORY_TEST = "SomeTopicConnectionFactory"; - - @Test - public void testGetJMSBridge() throws Exception { - Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new JMSModule()); - EventBridge bridge = injector.getInstance(EventBridge.class); - - assertNotNull(bridge); - assertTrue(bridge instanceof JMSBridge); - } - - @Test - public void testUseProperties() { - Module module = binder -> JMSModule.contributeTopicConnectionFactory(binder, TOPIC_CONNECTION_FACTORY_TEST); - - Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new JMSModule(), module); - JMSBridge bridge = (JMSBridge) injector.getInstance(EventBridge.class); - - assertEquals(TOPIC_CONNECTION_FACTORY_TEST, bridge.getTopicConnectionFactoryName()); - } - - @Test - public void testUseDefaultProperties() throws Exception { - Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new JMSModule()); - JMSBridge bridge = (JMSBridge) injector.getInstance(EventBridge.class); - - assertEquals(JMSBridge.TOPIC_CONNECTION_FACTORY_DEFAULT, bridge.getTopicConnectionFactoryName()); - } - - class DefaultBindings implements Module { - @Override - public void configure(Binder binder) { - binder.bindMap(String.class, Constants.PROPERTIES_MAP); - binder.bind(DataDomain.class).toInstance(DOMAIN); - binder.bind(EventManager.class).toInstance(EVENT_MANAGER); - binder.bind(TransactionManager.class).to(DefaultTransactionManager.class); - binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class); - binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); - binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); - } - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/pom.xml ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/pom.xml b/eventbridges/cayenne-xmpp/pom.xml deleted file mode 100644 index e57dc8f..0000000 --- a/eventbridges/cayenne-xmpp/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>cayenne-eventbridges-parent</artifactId> - <groupId>org.apache.cayenne</groupId> - <version>4.1.M2-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>cayenne-xmpp</artifactId> - <name>cayenne-xmpp: Cayenne XMPP Event bridge</name> - <packaging>jar</packaging> - - <dependencies> - <dependency> - <groupId>jivesoftware</groupId> - <artifactId>smack</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>jivesoftware</groupId> - <artifactId>smackx</artifactId> - <scope>provided</scope> - </dependency> - </dependencies> - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridge.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridge.java b/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridge.java deleted file mode 100644 index d506d6c..0000000 --- a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridge.java +++ /dev/null @@ -1,308 +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.cayenne.event; - -import org.apache.cayenne.CayenneRuntimeException; -import org.apache.cayenne.util.Base64Codec; -import org.apache.cayenne.util.Util; -import org.jivesoftware.smack.GroupChat; -import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.SSLXMPPConnection; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.Message; -import org.jivesoftware.smack.packet.Packet; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -/** - * An EventBridge implementation based on XMPP protocol and Smack XMPP client library. - * What's good about XMPP (Extensible Messaging and Presence Protocol, an IETF standard - * protocol that grew up from Jabber IM) is that generally it has fewer or no deployment - * limitations (unlike JMS and JGroups that are generally a good solution for local - * controlled networks). Also it provides lots of additional information for free, such as - * presence, and much more. - * <p> - * This implementation is based on Smack XMPP client library from JiveSoftware. - * </p> - * - * @since 1.2 - */ -public class XMPPBridge extends EventBridge { - - public static final String XMPP_HOST_PROPERTY = "cayenne.XMPPBridge.xmppHost"; - - /** - * An optional property, port 5222 is used as default XMPP port. - */ - public static final String XMPP_PORT_PROPERTY = "cayenne.XMPPBridge.xmppPort"; - - /** - * An optional property, "conference" is used as default chat service. - */ - public static final String XMPP_CHAT_SERVICE_PROPERTY = "cayenne.XMPPBridge.xmppChatService"; - - public static final String XMPP_SECURE_CONNECTION_PROPERTY = "cayenne.XMPPBridge.xmppSecure"; - public static final String XMPP_LOGIN_PROPERTY = "cayenne.XMPPBridge.xmppLogin"; - public static final String XMPP_PASSWORD_PROPERTY = "cayenne.XMPPBridge.xmppPassword"; - - static final String DEFAULT_CHAT_SERVICE = "conference"; - static final int DEFAULT_XMPP_PORT = 5222; - static final int DEFAULT_XMPP_SECURE_PORT = 5223; - - protected boolean secureConnection; - protected String loginId; - protected String password; - protected String xmppHost; - protected int xmppPort; - protected String chatService; - protected String sessionHandle; - - protected XMPPConnection connection; - protected GroupChat groupChat; - protected boolean connected; - - /** - * Creates an XMPPBridge. External subject will be used as the chat group name. - */ - public XMPPBridge(EventSubject localSubject, String externalSubject) { - this(Collections.singleton(localSubject), externalSubject); - } - - /** - * Creates an XMPPBridge. External subject will be used as the chat group name. - */ - public XMPPBridge(Collection<EventSubject> localSubjects, String externalSubject) { - super(localSubjects, externalSubject); - - // generate a unique session handle... users can override it to use a specific - // handle... - this.sessionHandle = "cayenne-xmpp-" + System.currentTimeMillis(); - } - - public XMPPBridge(Collection<EventSubject> localSubjects, String externalSubject, Map<String, String> properties) { - this(localSubjects, externalSubject); - - this.chatService = properties.get(XMPP_CHAT_SERVICE_PROPERTY); - this.xmppHost = properties.get(XMPP_HOST_PROPERTY); - - this.loginId = properties.get(XMPP_LOGIN_PROPERTY); - this.password = properties.get(XMPP_PASSWORD_PROPERTY); - - String secureConnectionString = properties.get(XMPP_SECURE_CONNECTION_PROPERTY); - secureConnection = "true".equalsIgnoreCase(secureConnectionString); - - String portString = properties.get(XMPP_PORT_PROPERTY); - if (portString != null) { - try { - this.xmppPort = Integer.parseInt(portString); - } catch (NumberFormatException e) { - throw new CayenneRuntimeException("Invalid port: %s", portString); - } - } - } - - public String getXmppHost() { - return xmppHost; - } - - public void setXmppHost(String xmppHost) { - this.xmppHost = xmppHost; - } - - public int getXmppPort() { - return xmppPort; - } - - public void setXmppPort(int xmppPort) { - this.xmppPort = xmppPort; - } - - public String getLoginId() { - return loginId; - } - - public void setLoginId(String loginId) { - this.loginId = loginId; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public boolean isSecureConnection() { - return secureConnection; - } - - public void setSecureConnection(boolean secureConnection) { - this.secureConnection = secureConnection; - } - - public String getChatService() { - return chatService; - } - - public void setChatService(String chatService) { - this.chatService = chatService; - } - - public String getSessionHandle() { - return sessionHandle; - } - - public void setSessionHandle(String sessionHandle) { - this.sessionHandle = sessionHandle; - } - - @Override - protected void startupExternal() throws Exception { - - // validate settings - if (xmppHost == null) { - throw new CayenneRuntimeException("Null 'xmppHost', can't start XMPPBridge"); - } - - // shutdown old bridge - if (connected) { - shutdownExternal(); - } - - try { - // connect and log in to chat - if (secureConnection) { - int port = xmppPort > 0 ? xmppPort : DEFAULT_XMPP_SECURE_PORT; - this.connection = new SSLXMPPConnection(xmppHost, port); - } else { - int port = xmppPort > 0 ? xmppPort : DEFAULT_XMPP_PORT; - this.connection = new XMPPConnection(xmppHost, port); - } - - if (loginId != null) { - // it is important to provide a (pseudo) globally unique string as the - // third argument ("sessionHandle" is such string); without it same - // loginId can not be reused from the same machine. - connection.login(loginId, password, sessionHandle); - } else { - connection.loginAnonymously(); - } - } catch (XMPPException e) { - throw new CayenneRuntimeException("Error connecting to XMPP Server: %s", e.getLocalizedMessage()); - } - - String service = chatService != null ? chatService : DEFAULT_CHAT_SERVICE; - try { - groupChat = connection.createGroupChat(externalSubject + '@' + service + "." + connection.getHost()); - groupChat.join(sessionHandle); - groupChat.addMessageListener(new XMPPListener()); - } catch (XMPPException e) { - throw new CayenneRuntimeException("Error setting up a group chat: %s", e.getLocalizedMessage()); - } - - this.connected = true; - } - - @Override - protected void shutdownExternal() throws Exception { - if (groupChat != null) { - groupChat.leave(); - groupChat = null; - } - - if (connection != null) { - connection.close(); - connection = null; - } - - connected = false; - } - - @Override - protected void sendExternalEvent(CayenneEvent localEvent) throws Exception { - - Message message = groupChat.createMessage(); - message.setBody(serializeToString(localEvent)); - - // set thread to our session handle to be able to discard messages from self - message.setThread(sessionHandle); - - groupChat.sendMessage(message); - } - - class XMPPListener implements PacketListener { - - public void processPacket(Packet packet) { - - if (packet instanceof Message) { - Message message = (Message) packet; - - // filter our own messages - if (sessionHandle.equals(message.getThread())) { - String payload = message.getBody(); - try { - Object event = deserializeFromString(payload); - if (event instanceof CayenneEvent) { - onExternalEvent((CayenneEvent) event); - } - } catch (Exception ex) { - // ignore for now... need to add logging. - } - } - } - } - } - - /** - * Decodes the String (assuming it is using Base64 encoding), and then deserializes - * object from the byte array. - */ - static Object deserializeFromString(String string) throws Exception { - if (Util.isEmptyString(string)) { - return null; - } - - byte[] bytes = Base64Codec.decodeBase64(string.getBytes()); - ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes)); - Object object = in.readObject(); - in.close(); - return object; - } - - /** - * Serializes object and then encodes it using Base64 encoding. - */ - static String serializeToString(Object object) throws Exception { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(bytes); - out.writeObject(object); - out.close(); - - return new String(Base64Codec.encodeBase64(bytes.toByteArray())); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridgeFactory.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridgeFactory.java b/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridgeFactory.java deleted file mode 100644 index 7934752..0000000 --- a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridgeFactory.java +++ /dev/null @@ -1,41 +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.cayenne.event; - -import java.util.Collection; -import java.util.Map; - -/** - * A factory of XMPPBridge. Note that to deploy an XMPPBridge, you need to have - * <em>smack.jar</em> library in the runtime. - * - * @since 1.2 - */ -public class XMPPBridgeFactory implements EventBridgeFactory { - - @Override - public EventBridge createEventBridge( - Collection<EventSubject> localSubjects, - String externalSubject, - Map<String, String> properties) { - return new XMPPBridge(localSubjects, externalSubject, properties); - } - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridgeProvider.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridgeProvider.java b/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridgeProvider.java deleted file mode 100644 index 38c9874..0000000 --- a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPBridgeProvider.java +++ /dev/null @@ -1,50 +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.cayenne.event; - -import org.apache.cayenne.access.DataDomain; -import org.apache.cayenne.access.DataRowStore; -import org.apache.cayenne.configuration.Constants; -import org.apache.cayenne.di.DIRuntimeException; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.di.Provider; - -import java.util.Collections; -import java.util.Map; - -public class XMPPBridgeProvider implements Provider<EventBridge> { - - @Inject - protected DataDomain dataDomain; - - @Inject(XMPPModule.XMPP_BRIDGE_PROPERTIES_MAP) - Map<String, String> properties; - - @Override - public EventBridge get() throws DIRuntimeException { - EventSubject snapshotEventSubject = EventSubject.getSubject(DataRowStore.class.getClass(), dataDomain.getName()); - - return new XMPPBridge( - Collections.singleton(snapshotEventSubject), - EventBridge.convertToExternalSubject(snapshotEventSubject), - properties); - } - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPModule.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPModule.java b/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPModule.java deleted file mode 100644 index 83c8f0a..0000000 --- a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPModule.java +++ /dev/null @@ -1,71 +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.cayenne.event; - -import org.apache.cayenne.di.Binder; -import org.apache.cayenne.di.MapBuilder; -import org.apache.cayenne.di.Module; - -/** - * @since 4.0 - */ -public class XMPPModule implements Module { - - /** - * A DI container key for the Map<String, String> storing - * {@link org.apache.cayenne.event.XMPPBridge} properties - * - * @since 4.0 - */ - public static final String XMPP_BRIDGE_PROPERTIES_MAP = "cayenne.server.xmpp_bridge"; - - public static void contributeHost(Binder binder, String host) { - contributeProperties(binder).put(XMPPBridge.XMPP_HOST_PROPERTY, host); - } - - public static void contributePort(Binder binder, int port) { - contributeProperties(binder).put(XMPPBridge.XMPP_PORT_PROPERTY, Integer.toString(port)); - } - - public static void contributeLogin(Binder binder, String login, String password) { - contributeProperties(binder).put(XMPPBridge.XMPP_LOGIN_PROPERTY, login); - contributeProperties(binder).put(XMPPBridge.XMPP_PASSWORD_PROPERTY, password); - } - - public static void contributeChatService(Binder binder, String chatService) { - contributeProperties(binder).put(XMPPBridge.XMPP_CHAT_SERVICE_PROPERTY, chatService); - } - - public static void contributeSecureConnection(Binder binder, boolean secure) { - contributeProperties(binder).put(XMPPBridge.XMPP_SECURE_CONNECTION_PROPERTY, Boolean.toString(secure)); - } - - private static MapBuilder<String> contributeProperties(Binder binder) { - return binder.bindMap(String.class, XMPP_BRIDGE_PROPERTIES_MAP); - } - - @Override - public void configure(Binder binder) { - // init properties' defaults - contributeChatService(binder, XMPPBridge.DEFAULT_CHAT_SERVICE); - - binder.bind(EventBridge.class).toProvider(XMPPBridgeProvider.class); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPServerModuleProvider.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPServerModuleProvider.java b/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPServerModuleProvider.java deleted file mode 100644 index e8cf3da..0000000 --- a/eventbridges/cayenne-xmpp/src/main/java/org/apache/cayenne/event/XMPPServerModuleProvider.java +++ /dev/null @@ -1,50 +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.cayenne.event; - -import java.util.Collection; -import java.util.Collections; - -import org.apache.cayenne.configuration.server.CayenneServerModuleProvider; -import org.apache.cayenne.configuration.server.ServerModule; -import org.apache.cayenne.di.Module; - -/** - * @since 4.0 - */ -public class XMPPServerModuleProvider implements CayenneServerModuleProvider { - - @Override - public Module module() { - return new XMPPModule(); - } - - @Override - public Class<? extends Module> moduleType() { - return XMPPModule.class; - } - - @SuppressWarnings("unchecked") - @Override - public Collection<Class<? extends Module>> overrides() { - Collection modules = Collections.singletonList(ServerModule.class); - return modules; - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/main/resources/META-INF/services/org.apache.cayenne.configuration.server.CayenneServerModuleProvider ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/main/resources/META-INF/services/org.apache.cayenne.configuration.server.CayenneServerModuleProvider b/eventbridges/cayenne-xmpp/src/main/resources/META-INF/services/org.apache.cayenne.configuration.server.CayenneServerModuleProvider deleted file mode 100644 index 00bce56..0000000 --- a/eventbridges/cayenne-xmpp/src/main/resources/META-INF/services/org.apache.cayenne.configuration.server.CayenneServerModuleProvider +++ /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. -################################################################## - -org.apache.cayenne.event.XMPPServerModuleProvider \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/CayenneXMPPModuleProviderTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/CayenneXMPPModuleProviderTest.java b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/CayenneXMPPModuleProviderTest.java deleted file mode 100644 index 0826f7c..0000000 --- a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/CayenneXMPPModuleProviderTest.java +++ /dev/null @@ -1,36 +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.cayenne.event; - -import org.apache.cayenne.configuration.server.CayenneServerModuleProvider; -import org.apache.cayenne.unit.util.ModuleProviderChecker; -import org.junit.Test; - -/** - * @since 4.0 - */ -public class CayenneXMPPModuleProviderTest { - - @Test - public void testAutoLoadable() { - ModuleProviderChecker.testProviderPresent(XMPPServerModuleProvider.class, CayenneServerModuleProvider.class); - } - -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeFactoryTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeFactoryTest.java b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeFactoryTest.java deleted file mode 100644 index b5aa80a..0000000 --- a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeFactoryTest.java +++ /dev/null @@ -1,72 +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.cayenne.event; - -import org.junit.Test; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class XMPPBridgeFactoryTest { - - protected Collection<EventSubject> subjects = Collections.singleton(new EventSubject("test")); - protected String externalSubject = "subject"; - - @Test - public void testCreateEventBridge() { - EventBridge bridge = new XMPPBridgeFactory().createEventBridge( - subjects, - externalSubject, - Collections.<String, String>emptyMap()); - - assertTrue(bridge instanceof XMPPBridge); - assertEquals(subjects, bridge.getLocalSubjects()); - assertEquals(externalSubject, bridge.getExternalSubject()); - } - - @Test - public void testUseMapPropertiesSetter() throws Exception { - XMPPBridgeFactory bridgeFactory = new XMPPBridgeFactory(); - Map<String, String> properties = new HashMap<>(); - - properties.put(XMPPBridge.XMPP_HOST_PROPERTY, XMPPBridgeProviderTest.HOST_TEST); - properties.put(XMPPBridge.XMPP_CHAT_SERVICE_PROPERTY, XMPPBridgeProviderTest.CHAT_SERVICE_TEST); - properties.put(XMPPBridge.XMPP_LOGIN_PROPERTY, XMPPBridgeProviderTest.LOGIN_TEST); - properties.put(XMPPBridge.XMPP_PASSWORD_PROPERTY, XMPPBridgeProviderTest.PASSWORD_TEST); - properties.put(XMPPBridge.XMPP_SECURE_CONNECTION_PROPERTY, String.valueOf(XMPPBridgeProviderTest.SECURE_CONNECTION_TEST)); - properties.put(XMPPBridge.XMPP_PORT_PROPERTY, String.valueOf(XMPPBridgeProviderTest.PORT_TEST)); - - XMPPBridge bridge = (XMPPBridge) bridgeFactory.createEventBridge(subjects, - externalSubject, - properties); - - assertEquals(bridge.getXmppHost(), XMPPBridgeProviderTest.HOST_TEST); - assertEquals(bridge.getChatService(), XMPPBridgeProviderTest.CHAT_SERVICE_TEST); - assertEquals(bridge.getLoginId(), XMPPBridgeProviderTest.LOGIN_TEST); - assertEquals(bridge.getPassword(), XMPPBridgeProviderTest.PASSWORD_TEST); - assertEquals(bridge.getXmppPort(), XMPPBridgeProviderTest.PORT_TEST); - assertEquals(bridge.isSecureConnection(), XMPPBridgeProviderTest.SECURE_CONNECTION_TEST); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java deleted file mode 100644 index f36d495..0000000 --- a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeProviderTest.java +++ /dev/null @@ -1,105 +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.cayenne.event; - -import org.apache.cayenne.access.DataDomain; -import org.apache.cayenne.configuration.Constants; -import org.apache.cayenne.configuration.DefaultRuntimeProperties; -import org.apache.cayenne.configuration.RuntimeProperties; -import org.apache.cayenne.di.Binder; -import org.apache.cayenne.di.DIBootstrap; -import org.apache.cayenne.di.Injector; -import org.apache.cayenne.di.Module; -import org.apache.cayenne.log.Slf4jJdbcEventLogger; -import org.apache.cayenne.log.JdbcEventLogger; -import org.apache.cayenne.tx.DefaultTransactionFactory; -import org.apache.cayenne.tx.DefaultTransactionManager; -import org.apache.cayenne.tx.TransactionFactory; -import org.apache.cayenne.tx.TransactionManager; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -public class XMPPBridgeProviderTest { - - private final DataDomain DOMAIN = new DataDomain("test"); - private final EventManager EVENT_MANAGER = new DefaultEventManager(); - protected static final String HOST_TEST = "somehost.com"; - protected static final String CHAT_SERVICE_TEST = "conference"; - protected static final String LOGIN_TEST = "login"; - protected static final String PASSWORD_TEST = "password"; - protected static final boolean SECURE_CONNECTION_TEST = true; - protected static final int PORT_TEST = 12345; - - @Test - public void testGetXMPPBridge() throws Exception { - Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new XMPPModule()); - EventBridge bridge = injector.getInstance(EventBridge.class); - - assertNotNull(bridge); - assertTrue(bridge instanceof XMPPBridge); - } - - @Test - public void testUseProperties() throws Exception { - Module module = binder -> { - XMPPModule.contributeSecureConnection(binder, SECURE_CONNECTION_TEST); - XMPPModule.contributeHost(binder, HOST_TEST); - XMPPModule.contributePort(binder, PORT_TEST); - XMPPModule.contributeLogin(binder, LOGIN_TEST, PASSWORD_TEST); - XMPPModule.contributeChatService(binder, CHAT_SERVICE_TEST); - }; - - Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new XMPPModule(), module); - XMPPBridge bridge = (XMPPBridge) injector.getInstance(EventBridge.class); - - assertEquals(HOST_TEST, bridge.getXmppHost()); - assertEquals(CHAT_SERVICE_TEST, bridge.getChatService()); - assertEquals(LOGIN_TEST, bridge.getLoginId()); - assertEquals(PASSWORD_TEST, bridge.getPassword()); - assertEquals(SECURE_CONNECTION_TEST, bridge.isSecureConnection()); - assertEquals(PORT_TEST, bridge.getXmppPort()); - } - - @Test - public void testUseDefaultProperties() throws Exception { - Injector injector = DIBootstrap.createInjector(new DefaultBindings(), new XMPPModule()); - XMPPBridge bridge = (XMPPBridge) injector.getInstance(EventBridge.class); - - assertEquals(XMPPBridge.DEFAULT_CHAT_SERVICE, bridge.getChatService()); - assertEquals(0, bridge.getXmppPort()); - assertEquals(false, bridge.isSecureConnection()); - } - - class DefaultBindings implements Module { - @Override - public void configure(Binder binder) { - binder.bindMap(String.class, Constants.PROPERTIES_MAP); - binder.bind(DataDomain.class).toInstance(DOMAIN); - binder.bind(EventManager.class).toInstance(EVENT_MANAGER); - binder.bind(TransactionManager.class).to(DefaultTransactionManager.class); - binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class); - binder.bind(JdbcEventLogger.class).to(Slf4jJdbcEventLogger.class); - binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class); - } - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeTest.java ---------------------------------------------------------------------- diff --git a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeTest.java b/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeTest.java deleted file mode 100644 index 5422c3a..0000000 --- a/eventbridges/cayenne-xmpp/src/test/java/org/apache/cayenne/event/XMPPBridgeTest.java +++ /dev/null @@ -1,54 +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.cayenne.event; - -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -/** - */ -public class XMPPBridgeTest { - - @Test - public void testEventSerialization() throws Exception { - Map<String, String> info = new HashMap<>(); - info.put("a", "b"); - CayenneEvent e = new CayenneEvent(this, this, info); - - String string = XMPPBridge.serializeToString(e); - assertNotNull(string); - - Object copy = XMPPBridge.deserializeFromString(string); - assertNotNull(copy); - assertTrue(copy instanceof CayenneEvent); - - CayenneEvent e2 = (CayenneEvent) copy; - assertEquals(info, e2.getInfo()); - assertNull(e2.getPostedBy()); - assertNull(e2.getSource()); - } -} http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/eventbridges/pom.xml ---------------------------------------------------------------------- diff --git a/eventbridges/pom.xml b/eventbridges/pom.xml deleted file mode 100644 index 2c2d0f2..0000000 --- a/eventbridges/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ 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. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>cayenne-parent</artifactId> - <groupId>org.apache.cayenne</groupId> - <version>4.1.M2-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>cayenne-eventbridges-parent</artifactId> - <name>cayenne-eventbridges-parent: Event bridges implementations parent</name> - <packaging>pom</packaging> - - <modules> - <module>cayenne-jgroups</module> - <module>cayenne-jms</module> - <module>cayenne-xmpp</module> - </modules> - - <dependencies> - <dependency> - <groupId>org.apache.cayenne</groupId> - <artifactId>cayenne-server</artifactId> - <version>${project.version}</version> - </dependency> - - <!-- Test dependencies --> - <dependency> - <groupId>org.apache.cayenne</groupId> - <artifactId>cayenne-server</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <!-- This ensures LICENSE and NOTICE inclusion in all jars --> - <plugin> - <artifactId>maven-remote-resources-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>process</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cayenne/blob/ab1fd0bf/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 7444379..92435d9 100644 --- a/pom.xml +++ b/pom.xml @@ -74,7 +74,9 @@ <module>cayenne-web</module> <module>cayenne-osgi</module> <module>cayenne-rop-server</module> - <module>eventbridges</module> + <module>cayenne-jgroups</module> + <module>cayenne-jms</module> + <module>cayenne-xmpp</module> <module>itests</module> <module>maven-plugins</module> <module>modeler</module>