[kune-commits] r1781 - in trunk: . src/main/java/cc/kune/core/server src/main/java/cc/kune/core/server/persist src/main/java/cc/kune/core/server/properties src/main/java/cc/kune/core/server/xmpp src/main/resources
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Sun Mar 25 17:30:31 CEST 2012
Author: vjrj_
Date: 2012-03-25 17:30:31 +0200 (Sun, 25 Mar 2012)
New Revision: 1781
Added:
trunk/src/main/java/cc/kune/core/server/xmpp/XmppRosterProviderMock.java
Modified:
trunk/INSTALL
trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
trunk/src/main/java/cc/kune/core/server/persist/DataSourceOpenfirePersistModule.java
trunk/src/main/java/cc/kune/core/server/properties/KuneProperties.java
trunk/src/main/resources/kune.properties
Log:
openfire connection optional
Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL 2012-03-25 15:05:47 UTC (rev 1780)
+++ trunk/INSTALL 2012-03-25 15:30:31 UTC (rev 1781)
@@ -205,6 +205,8 @@
==Appendix A: Configuration of Openfire xmpp server==
+If you want to INSTALL kune without openfire dependency (useful for development or testing), you can skip this part (configure kune.openfire.ignore in kune.properties accordingly).
+
Install openfire in your system: http://www.igniterealtime.org/downloads/index.jsp
In debian and derivatives, to install the .deb its highly recomended.
Modified: trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2012-03-25 15:05:47 UTC (rev 1780)
+++ trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2012-03-25 15:30:31 UTC (rev 1781)
@@ -46,6 +46,7 @@
import cc.kune.core.server.persist.DataSourceKunePersistModule;
import cc.kune.core.server.persist.DataSourceOpenfirePersistModule;
import cc.kune.core.server.persist.KuneTransactional;
+import cc.kune.core.server.properties.KuneProperties;
import cc.kune.core.server.rack.RackBuilder;
import cc.kune.core.server.rack.RackModule;
import cc.kune.core.server.rack.filters.ForwardFilter;
@@ -177,16 +178,18 @@
protected void configureServlets() {
final DataSourceKunePersistModule kuneDataSource = new DataSourceKunePersistModule();
install(kuneDataSource);
- install(new DataSourceOpenfirePersistModule(kuneDataSource.getKuneProperties()));
+ final KuneProperties kuneProperties = kuneDataSource.getKuneProperties();
+ install(new DataSourceOpenfirePersistModule(kuneProperties));
bindInterceptor(annotatedWith(KuneTransactional.class), any(),
kuneDataSource.getTransactionInterceptor());
bindInterceptor(any(), annotatedWith(KuneTransactional.class),
kuneDataSource.getTransactionInterceptor());
+ filter("/*").through(DataSourceKunePersistModule.MY_DATA_SOURCE_ONE_FILTER_KEY);
- // more bindings
+ if (!kuneProperties.getBoolean(KuneProperties.SITE_OPENFIRE_IGNORE)) {
+ filter("/*").through(DataSourceOpenfirePersistModule.MY_DATA_SOURCE_TWO_FILTER_KEY);
+ }
- filter("/*").through(DataSourceKunePersistModule.MY_DATA_SOURCE_ONE_FILTER_KEY);
- filter("/*").through(DataSourceOpenfirePersistModule.MY_DATA_SOURCE_TWO_FILTER_KEY);
super.configureServlets();
}
});
Modified: trunk/src/main/java/cc/kune/core/server/persist/DataSourceOpenfirePersistModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/persist/DataSourceOpenfirePersistModule.java 2012-03-25 15:05:47 UTC (rev 1780)
+++ trunk/src/main/java/cc/kune/core/server/persist/DataSourceOpenfirePersistModule.java 2012-03-25 15:30:31 UTC (rev 1781)
@@ -10,6 +10,7 @@
import cc.kune.core.server.xmpp.OpenfireXmppRosterFinder;
import cc.kune.core.server.xmpp.OpenfireXmppRosterProvider;
import cc.kune.core.server.xmpp.XmppRosterProvider;
+import cc.kune.core.server.xmpp.XmppRosterProviderMock;
import com.google.inject.Key;
import com.google.inject.PrivateModule;
@@ -28,36 +29,41 @@
@Override
public void configure() {
- final JpaPersistModule jpm = new JpaPersistModule("openfire");
+ if (kuneProperties.getBoolean(KuneProperties.SITE_OPENFIRE_IGNORE)) {
+ bind(XmppRosterProvider.class).to(XmppRosterProviderMock.class).in(Singleton.class);
+ expose(XmppRosterProvider.class);
+ } else {
+ final JpaPersistModule jpm = new JpaPersistModule("openfire");
- final Properties dbProperties = new Properties();
+ final Properties dbProperties = new Properties();
- dbProperties.setProperty("hibernate.connection.url",
- kuneProperties.get(KuneProperties.SITE_OPENFIRE_DB_URL));
- dbProperties.setProperty("hibernate.connection.username",
- kuneProperties.get(KuneProperties.SITE_OPENFIRE_DB_USER));
- dbProperties.setProperty("hibernate.connection.password",
- kuneProperties.get(KuneProperties.SITE_OPENFIRE_DB_PASSWORD));
- dbProperties.setProperty("exclude-unlisted-classes", "true");
+ dbProperties.setProperty("hibernate.connection.url",
+ kuneProperties.get(KuneProperties.SITE_OPENFIRE_DB_URL));
+ dbProperties.setProperty("hibernate.connection.username",
+ kuneProperties.get(KuneProperties.SITE_OPENFIRE_DB_USER));
+ dbProperties.setProperty("hibernate.connection.password",
+ kuneProperties.get(KuneProperties.SITE_OPENFIRE_DB_PASSWORD));
+ dbProperties.setProperty("exclude-unlisted-classes", "true");
- jpm.properties(dbProperties);
- install(jpm.addFinder(OpenfireXmppRosterFinder.class));
- expose(OpenfireXmppRosterFinder.class);
+ jpm.properties(dbProperties);
+ install(jpm.addFinder(OpenfireXmppRosterFinder.class));
+ expose(OpenfireXmppRosterFinder.class);
- bind(XmppRosterProvider.class).to(OpenfireXmppRosterProvider.class).in(Singleton.class);
- expose(XmppRosterProvider.class);
+ bind(XmppRosterProvider.class).to(OpenfireXmppRosterProvider.class).in(Singleton.class);
+ expose(XmppRosterProvider.class);
- bind(Session.class).annotatedWith(DataSourceOpenfire.class).toProvider(
- DataSourceOpenfireSessionProvider.class);
- expose(Session.class).annotatedWith(DataSourceOpenfire.class);
+ bind(Session.class).annotatedWith(DataSourceOpenfire.class).toProvider(
+ DataSourceOpenfireSessionProvider.class);
+ expose(Session.class).annotatedWith(DataSourceOpenfire.class);
- final Provider<EntityManager> entityManagerProvider = binder().getProvider(EntityManager.class);
- bind(EntityManager.class).annotatedWith(DataSourceOpenfire.class).toProvider(entityManagerProvider);
- expose(EntityManager.class).annotatedWith(DataSourceOpenfire.class);
+ final Provider<EntityManager> entityManagerProvider = binder().getProvider(EntityManager.class);
+ bind(EntityManager.class).annotatedWith(DataSourceOpenfire.class).toProvider(entityManagerProvider);
+ expose(EntityManager.class).annotatedWith(DataSourceOpenfire.class);
- bind(MY_DATA_SOURCE_TWO_FILTER_KEY).to(CustomPersistFilter.class);
- expose(MY_DATA_SOURCE_TWO_FILTER_KEY);
+ bind(MY_DATA_SOURCE_TWO_FILTER_KEY).to(CustomPersistFilter.class);
+ expose(MY_DATA_SOURCE_TWO_FILTER_KEY);
- bind(GenericPersistenceInitializer.class).asEagerSingleton();
+ bind(GenericPersistenceInitializer.class).asEagerSingleton();
+ }
}
}
\ No newline at end of file
Modified: trunk/src/main/java/cc/kune/core/server/properties/KuneProperties.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/properties/KuneProperties.java 2012-03-25 15:05:47 UTC (rev 1780)
+++ trunk/src/main/java/cc/kune/core/server/properties/KuneProperties.java 2012-03-25 15:30:31 UTC (rev 1781)
@@ -61,6 +61,7 @@
String SITE_OPENFIRE_DB_PASSWORD = "kune.openfire.db.password";
String SITE_OPENFIRE_DB_URL = "kune.openfire.db.url";
String SITE_OPENFIRE_DB_USER = "kune.openfire.db.user";
+ String SITE_OPENFIRE_IGNORE = "kune.openfire.ignore";
String SITE_SHORTNAME = "kune.default.site.shortName";
String SITE_SMTP_DEFAULT_FROM = "kune.site.smtp.defaultfrom";
String SITE_SMTP_HOST = "kune.site.smtp.host";
Added: trunk/src/main/java/cc/kune/core/server/xmpp/XmppRosterProviderMock.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/xmpp/XmppRosterProviderMock.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/xmpp/XmppRosterProviderMock.java 2012-03-25 15:30:31 UTC (rev 1781)
@@ -0,0 +1,18 @@
+package cc.kune.core.server.xmpp;
+
+import java.util.Collection;
+import java.util.Collections;
+
+public class XmppRosterProviderMock implements XmppRosterProvider {
+
+ @Override
+ public Long count() {
+ return 0l;
+ }
+
+ @Override
+ public Collection<RosterItem> getRoster(final String user) {
+ return Collections.emptyList();
+ }
+
+}
Modified: trunk/src/main/resources/kune.properties
===================================================================
--- trunk/src/main/resources/kune.properties 2012-03-25 15:05:47 UTC (rev 1780)
+++ trunk/src/main/resources/kune.properties 2012-03-25 15:30:31 UTC (rev 1781)
@@ -47,11 +47,15 @@
kune.db.user = kune
kune.db.password = db4kune
+# if we should ignore openfire connection in serverside (useful just for testing/development)
+kune.openfire.ignore = false
+
# openfire db info:
kune.openfire.db.url = jdbc:mysql://localhost/kune_openfire?createDatabaseIfNotExist=false&useUnicode=true&characterEncoding=UTF-8
kune.openfire.db.user = kune
kune.openfire.db.password = db4kune
+
### Licenses
kune.default.license = by-sa-v3.0
More information about the kune-commits
mailing list