exo-jcr SVN: r3836 - in kernel/trunk/exo.kernel.component.common/src: test/java/org/exoplatform/services/rpc/impl and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2011-01-24 10:15:20 -0500 (Mon, 24 Jan 2011)
New Revision: 3836
Modified:
kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java
Log:
EXOJCR-1107 : The changes who fixed problem with method RPCService.executeCommandOnCoordinator() was committed.
Modified: kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2011-01-24 13:41:35 UTC (rev 3835)
+++ kernel/trunk/exo.kernel.component.common/src/main/java/org/exoplatform/services/rpc/impl/RPCServiceImpl.java 2011-01-24 15:15:20 UTC (rev 3836)
@@ -426,7 +426,7 @@
throw new RPCException("Command " + commandId + " unknown, please register your command first");
}
final Message msg = new Message();
- msg.setObject(new MessageBody(commandId, args));
+ msg.setObject(new MessageBody(dests.size() == 1 && dests != members ? dests.get(0) : null, commandId, args));
RspList rsps = AccessController.doPrivileged(new PrivilegedAction<RspList>()
{
public RspList run()
@@ -486,7 +486,15 @@
// Ensure that the service is fully started before trying to execute any command
startSignal.await();
MessageBody body = (MessageBody)msg.getObject();
- RemoteCommand command = getCommand(commandId = body.getCommandId());
+ commandId = body.getCommandId();
+ if (!body.accept(channel.getLocalAddress()))
+ {
+ if (LOG.isTraceEnabled())
+ LOG.trace("Command : " + commandId + " needs to be executed on the coordinator " +
+ "only and the local node is not the coordinator, the command will be ignored");
+ return null;
+ }
+ RemoteCommand command = getCommand(commandId);
if (command == null)
{
return new RPCException("Command " + commandId + " unkown, please register your command first");
@@ -888,18 +896,29 @@
private String commandId;
/**
- * The list of parameters;
+ * The list of parameters
*/
private Serializable[] args;
+
+ /**
+ * The hash code of the expected destination
+ */
+ private int destination;
public MessageBody()
{
}
- public MessageBody(String commandId, Serializable[] args)
+ /**
+ * @param dest The destination of the message
+ * @param commandId the id of the command to execute
+ * @param args the arguments to use
+ */
+ public MessageBody(Address dest, String commandId, Serializable[] args)
{
this.commandId = commandId;
this.args = args;
+ this.destination = dest == null ? 0 : dest.hashCode();
}
public String getCommandId()
@@ -910,6 +929,17 @@
public Serializable[] getArgs()
{
return args;
+ }
+
+ /**
+ * Indicates whether or not the given message body accepts the given address
+ * @param address the address to check
+ * @return <code>true</code> if the message is for everybody or if the given address is the expected address,
+ * <code>false</code> otherwise
+ */
+ public boolean accept(Address address)
+ {
+ return destination == 0 || destination == address.hashCode();
}
/**
@@ -917,6 +947,11 @@
*/
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
+ boolean unicast = in.readBoolean();
+ if (unicast)
+ {
+ this.destination = in.readInt();
+ }
this.commandId = in.readUTF();
int size = in.readInt();
if (size == -1)
@@ -938,6 +973,12 @@
*/
public void writeExternal(ObjectOutput out) throws IOException
{
+ boolean unicast = destination != 0;
+ out.writeBoolean(unicast);
+ if (unicast)
+ {
+ out.writeInt(destination);
+ }
out.writeUTF(commandId);
if (args == null)
{
Modified: kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java
===================================================================
--- kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java 2011-01-24 13:41:35 UTC (rev 3835)
+++ kernel/trunk/exo.kernel.component.common/src/test/java/org/exoplatform/services/rpc/impl/TestRPCServiceImpl.java 2011-01-24 15:15:20 UTC (rev 3836)
@@ -33,6 +33,7 @@
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;
@@ -824,6 +825,7 @@
catch (Throwable e)
{
error.set(e);
+ e.printStackTrace();
}
finally
{
@@ -1182,6 +1184,74 @@
}
}
+ public void testExecOnCoordinator() throws Exception
+ {
+ InitParams params = new InitParams();
+ ValueParam paramConf = new ValueParam();
+ paramConf.setName(RPCServiceImpl.PARAM_JGROUPS_CONFIG);
+ paramConf.setValue("jar:/conf/portal/udp.xml");
+ params.addParameter(paramConf);
+
+ final List<Boolean> calledCommands = Collections.synchronizedList(new ArrayList<Boolean>());
+
+ RPCServiceImpl service1 = null;
+ RPCServiceImpl service2 = null;
+ try
+ {
+ service1 = new RPCServiceImpl(container.getContext(), params, configManager);
+ RemoteCommand service1Cmd = new RemoteCommand()
+ {
+ public String getId()
+ {
+ return "CoordinatorExecutedCommand";
+ }
+
+ public String execute(Serializable[] args) throws Throwable
+ {
+ calledCommands.add(Boolean.TRUE);
+ return "service 1";
+ }
+ };
+ service1.registerCommand(service1Cmd);
+
+ service2 = new RPCServiceImpl(container.getContext(), params, configManager);
+ RemoteCommand service2Cmd = new RemoteCommand()
+ {
+ public String getId()
+ {
+ return "CoordinatorExecutedCommand";
+ }
+
+ public String execute(Serializable[] args) throws Throwable
+ {
+ calledCommands.add(Boolean.TRUE);
+ return "service 2";
+ }
+ };
+ service2.registerCommand(service2Cmd);
+ // starting services
+ service1.start();
+ service2.start();
+
+ Object o = service1.executeCommandOnCoordinator(service1Cmd, true);
+ assertEquals("service 1", o);
+
+ // it should be executed once
+ assertEquals(1, calledCommands.size());
+ }
+ finally
+ {
+ if (service1 != null)
+ {
+ service1.stop();
+ }
+ if (service2 != null)
+ {
+ service2.stop();
+ }
+ }
+ }
+
private static class MyListener implements TopologyChangeListener
{
13 years, 4 months
exo-jcr SVN: r3835 - core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2011-01-24 08:41:35 -0500 (Mon, 24 Jan 2011)
New Revision: 3835
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
Log:
EXOJCR-1148: DBCreator cleanup
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-01-24 13:20:31 UTC (rev 3834)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-01-24 13:41:35 UTC (rev 3835)
@@ -77,31 +77,16 @@
public static final String PASSWORD_TEMPLATE = "${password}";
/**
- * Driver class name.
- */
- protected final String driver;
-
- /**
* Server url.
*/
protected final String serverUrl;
/**
- * User name with administrative rights for connection to server.
+ * Connection properties.
*/
- protected final String adminName;
+ protected final Map<String, String> connectionProperties;
/**
- * User's password.
- */
- protected final String adminPwd;
-
- /**
- * Internal login connection property needed for Oracle.
- */
- protected final String internal_logon;
-
- /**
* DDL script database creation.
*/
protected final String dbScript;
@@ -117,11 +102,6 @@
protected final String dbPassword;
/**
- * Connection properties.
- */
- protected final Map<String, String> connectionProperties;
-
- /**
* DBCreator constructor.
*
* @param params
@@ -138,44 +118,38 @@
if (prop != null)
{
- this.driver = prop.getProperty(DB_DRIVER);
- if (driver == null)
+ if (prop.getProperty(DB_DRIVER) == null)
{
throw new ConfigurationException("driverClassName expected in db-connection properties section");
}
- this.serverUrl = prop.getProperty(DB_URL);
+ serverUrl = prop.getProperty(DB_URL);
if (serverUrl == null)
{
throw new ConfigurationException("url expected in db-connection properties section");
}
- this.adminName = prop.getProperty(DB_USERNAME);
- if (adminName == null)
+ if (prop.getProperty(DB_USERNAME) == null)
{
throw new ConfigurationException("username expected in db-connection properties section");
}
- this.adminPwd = prop.getProperty(DB_PASSWORD);
- if (adminPwd == null)
+ if (prop.getProperty(DB_PASSWORD) == null)
{
throw new ConfigurationException("password expected in db-connection properties section");
}
- this.internal_logon = prop.getProperty(DB_ORCL_INTERNAL_LOGON);
-
// Store all connection properties into single map
Iterator<Property> pit = prop.getPropertyIterator();
- Map<String, String> tempMap = new HashMap<String, String>();
+ connectionProperties = new HashMap<String, String>();
while (pit.hasNext())
{
Property p = pit.next();
if (!p.getName().equalsIgnoreCase(DB_URL))
{
- tempMap.put(p.getName(), p.getValue());
+ connectionProperties.put(p.getName(), p.getValue());
}
}
- connectionProperties = tempMap;
}
else
{
@@ -236,13 +210,14 @@
Connection conn = null;
try
{
- Class.forName(driver);
+ Class.forName(connectionProperties.get(DB_DRIVER));
conn = SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
{
public Connection run() throws Exception
{
- return DriverManager.getConnection(serverUrl, adminName, adminPwd);
+ return DriverManager.getConnection(serverUrl, connectionProperties.get(DB_USERNAME),
+ connectionProperties.get(DB_PASSWORD));
}
});
}
@@ -252,7 +227,7 @@
}
catch (ClassNotFoundException e)
{
- throw new DBCreatorException("Can't load the JDBC driver " + driver, e);
+ throw new DBCreatorException("Can't load the JDBC driver " + connectionProperties.get(DB_DRIVER), e);
}
String dbProductName;
@@ -316,13 +291,14 @@
Connection conn = null;
try
{
- Class.forName(driver);
+ Class.forName(connectionProperties.get(DB_DRIVER));
conn = SecurityHelper.doPrivilegedSQLExceptionAction(new PrivilegedExceptionAction<Connection>()
{
public Connection run() throws Exception
{
- return DriverManager.getConnection(serverUrl, adminName, adminPwd);
+ return DriverManager.getConnection(serverUrl, connectionProperties.get(DB_USERNAME),
+ connectionProperties.get(DB_PASSWORD));
}
});
}
@@ -332,7 +308,7 @@
}
catch (ClassNotFoundException e)
{
- throw new DBCreatorException("Can't load the JDBC driver " + driver, e);
+ throw new DBCreatorException("Can't load the JDBC driver " + connectionProperties.get(DB_DRIVER), e);
}
String dbProductName;
13 years, 4 months
exo-jcr SVN: r3834 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2011-01-24 08:20:31 -0500 (Mon, 24 Jan 2011)
New Revision: 3834
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
Log:
EXOJCR-1148: DBConnectionInfo returns only properties map
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-01-24 13:18:50 UTC (rev 3833)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-01-24 13:20:31 UTC (rev 3834)
@@ -52,12 +52,10 @@
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.Serializable;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import javax.jcr.RepositoryException;
@@ -426,18 +424,11 @@
for (String dataSource : dataSourceNames)
{
// create related DB
- Map<String, String> refAddr = new HashMap<String, String>();
+ Map<String, String> refAddr = null;
try
{
DBConnectionInfo dbConnectionInfo = dbCreator.createDatabase(rEntry.getName() + "_" + dataSource);
- refAddr.put("driverClassName", dbConnectionInfo.getDriver());
- refAddr.put("url", dbConnectionInfo.getUrl());
- refAddr.put("username", dbConnectionInfo.getUsername());
- refAddr.put("password", dbConnectionInfo.getPassword());
- for (Entry<String, String> entry : dbConnectionInfo.getAdditionalProperties().entrySet())
- {
- refAddr.put(entry.getKey(), entry.getValue());
- }
+ refAddr = dbConnectionInfo.getProperties();
}
catch (DBCreatorException e)
{
@@ -519,19 +510,12 @@
for (String dataSource : dataSourceNames)
{
// get data base info
- Map<String, String> refAddr = new HashMap<String, String>();
+ Map<String, String> refAddr = null;
try
{
DBConnectionInfo dbConnectionInfo =
dbCreator.getDBConnectionInfo(repositoryEntry.getName() + "_" + dataSource);
- refAddr.put("driverClassName", dbConnectionInfo.getDriver());
- refAddr.put("url", dbConnectionInfo.getUrl());
- refAddr.put("username", dbConnectionInfo.getUsername());
- refAddr.put("password", dbConnectionInfo.getPassword());
- for (Entry<String, String> entry : dbConnectionInfo.getAdditionalProperties().entrySet())
- {
- refAddr.put(entry.getKey(), entry.getValue());
- }
+ refAddr = dbConnectionInfo.getProperties();
}
catch (DBCreatorException e)
{
13 years, 4 months
exo-jcr SVN: r3833 - in core/trunk/exo.core.component.database/src: test/java/org/exoplatform/services/database and 1 other directory.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2011-01-24 08:18:50 -0500 (Mon, 24 Jan 2011)
New Revision: 3833
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java
Log:
EXOJCR-1148: DBConnectionInfo uses only properties map
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java 2011-01-24 10:54:51 UTC (rev 3832)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java 2011-01-24 13:18:50 UTC (rev 3833)
@@ -28,103 +28,20 @@
*/
public class DBConnectionInfo
{
- /**
- * Driver class name.
- */
- private final String driver;
+ private final Map<String, String> connectionProperties;
/**
- * DB connection url;
- */
- private final String url;
-
- /**
- * DB connection user name;
- */
- private final String username;
-
- /**
- * User's password.
- */
- private final String password;
-
- private final Map<String, String> additionalProperties;
-
- /**
* DBConnectionInfo constructor.
- *
- * @param driver
- * driver class name
- * @param url
- * db connection url
- * @param username
- * db connection user name
- * @param password
- * user's password
+ * @param connectionProperties
+ * connection properties
*/
- public DBConnectionInfo(String driver, String url, String username, String password)
+ public DBConnectionInfo(Map<String, String> connectionProperties)
{
- this(driver, url, username, password, null);
+ this.connectionProperties = connectionProperties;
}
- /**
- * DBConnectionInfo constructor.
- *
- * @param driver
- * driver class name
- * @param url
- * db connection url
- * @param username
- * db connection user name
- * @param password
- * user's password
- * @param additionalProperties
- * additonal connection properties
- */
- public DBConnectionInfo(String driver, String url, String username, String password,
- Map<String, String> additionalProperties)
+ public Map<String, String> getProperties()
{
- this.driver = driver;
- this.url = url;
- this.username = username;
- this.password = password;
- this.additionalProperties = additionalProperties;
+ return connectionProperties;
}
-
- /**
- * @return the driver
- */
- public String getDriver()
- {
- return driver;
- }
-
- /**
- * @return the url
- */
- public String getUrl()
- {
- return url;
- }
-
- /**
- * @return the username
- */
- public String getUsername()
- {
- return username;
- }
-
- /**
- * @return the password
- */
- public String getPassword()
- {
- return password;
- }
-
- public Map<String, String> getAdditionalProperties()
- {
- return additionalProperties;
- }
}
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-01-24 10:54:51 UTC (rev 3832)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-01-24 13:18:50 UTC (rev 3833)
@@ -36,6 +36,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Map.Entry;
/**
* @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
@@ -44,6 +45,22 @@
public class DBCreator
{
+ private final static String DB_CONNECTION = "db-connection";
+
+ private final static String DB_DRIVER = "driverClassName";
+
+ private final static String DB_URL = "url";
+
+ private final static String DB_USERNAME = "username";
+
+ private final static String DB_PASSWORD = "password";
+
+ private final static String DB_ORCL_INTERNAL_LOGON = "internal_logon";
+
+ private final static String DB_CREATION = "db-creation";
+
+ private final static String DB_SCRIPT_PATH = "scriptPath";
+
/**
* Database template.
*/
@@ -100,9 +117,9 @@
protected final String dbPassword;
/**
- * Additional connection properties.
+ * Connection properties.
*/
- protected final Map<String, String> additionalProperties;
+ protected final Map<String, String> connectionProperties;
/**
* DBCreator constructor.
@@ -117,63 +134,58 @@
throw new ConfigurationException("Initializations parameters expected");
}
- PropertiesParam prop = params.getPropertiesParam("db-connection");
+ PropertiesParam prop = params.getPropertiesParam(DB_CONNECTION);
if (prop != null)
{
- this.driver = prop.getProperty("driverClassName");
+ this.driver = prop.getProperty(DB_DRIVER);
if (driver == null)
{
throw new ConfigurationException("driverClassName expected in db-connection properties section");
}
- this.serverUrl = prop.getProperty("url");
+ this.serverUrl = prop.getProperty(DB_URL);
if (serverUrl == null)
{
throw new ConfigurationException("url expected in db-connection properties section");
}
- this.adminName = prop.getProperty("username");
+ this.adminName = prop.getProperty(DB_USERNAME);
if (adminName == null)
{
throw new ConfigurationException("username expected in db-connection properties section");
}
- this.adminPwd = prop.getProperty("password");
+ this.adminPwd = prop.getProperty(DB_PASSWORD);
if (adminPwd == null)
{
throw new ConfigurationException("password expected in db-connection properties section");
}
- this.internal_logon = prop.getProperty("internal_logon");
+ this.internal_logon = prop.getProperty(DB_ORCL_INTERNAL_LOGON);
- // Store additional properties into map
+ // Store all connection properties into single map
Iterator<Property> pit = prop.getPropertyIterator();
-
- additionalProperties = new HashMap<String, String>();
-
+ Map<String, String> tempMap = new HashMap<String, String>();
while (pit.hasNext())
{
Property p = pit.next();
- String name = p.getName();
- if (name.equalsIgnoreCase("driverClassName") || name.equalsIgnoreCase("url")
- || name.equalsIgnoreCase("username") || name.equalsIgnoreCase("password")
- || name.equalsIgnoreCase("internal_logon"))
+ if (!p.getName().equalsIgnoreCase(DB_URL))
{
- continue;
+ tempMap.put(p.getName(), p.getValue());
}
- additionalProperties.put(name, p.getValue());
}
+ connectionProperties = tempMap;
}
else
{
throw new ConfigurationException("db-connection properties expected in initializations parameters");
}
- prop = params.getPropertiesParam("db-creation");
+ prop = params.getPropertiesParam(DB_CREATION);
if (prop != null)
{
- String scriptPath = prop.getProperty("scriptPath");
+ String scriptPath = prop.getProperty(DB_SCRIPT_PATH);
if (scriptPath != null)
{
try
@@ -190,13 +202,13 @@
throw new ConfigurationException("scriptPath expected in db-creation properties section");
}
- this.dbUserName = prop.getProperty("username");
+ this.dbUserName = prop.getProperty(DB_USERNAME);
if (dbUserName == null)
{
throw new ConfigurationException("username expected in db-creation properties section");
}
- this.dbPassword = prop.getProperty("password");
+ this.dbPassword = prop.getProperty(DB_PASSWORD);
if (dbPassword == null)
{
throw new ConfigurationException("password expected in db-creation properties section");
@@ -407,7 +419,17 @@
dbUrl = dbUrl + (dbUrl.endsWith("/") ? "" : "/") + dbName;
}
- return new DBConnectionInfo(driver, dbUrl, dbUserName, dbPassword, additionalProperties);
+ // clone connection properties
+ Map<String, String> connProperties = new HashMap<String, String>();
+
+ for (Entry<String, String> entry : this.connectionProperties.entrySet())
+ {
+ connProperties.put(entry.getKey(), entry.getValue());
+ }
+
+ connProperties.put(DB_URL, dbUrl);
+
+ return new DBConnectionInfo(connProperties);
}
/**
Modified: core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java 2011-01-24 10:54:51 UTC (rev 3832)
+++ core/trunk/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java 2011-01-24 13:18:50 UTC (rev 3833)
@@ -26,7 +26,6 @@
import org.exoplatform.services.naming.InitialContextInitializer;
import java.sql.Connection;
-import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
@@ -58,17 +57,16 @@
DBConnectionInfo dbInfo = dbCreator.createDatabase("testdb");
DBConnectionInfo dbInfo1 = dbCreator.getDBConnectionInfo("testdb");
- assertEquals(dbInfo.getDriver(), dbInfo1.getDriver());
- assertEquals(dbInfo.getPassword(), dbInfo1.getPassword());
- assertEquals(dbInfo.getUrl(), dbInfo1.getUrl());
- assertEquals(dbInfo.getUsername(), dbInfo1.getUsername());
+ Map<String, String> connProps = dbInfo.getProperties();
+ Map<String, String> connProps1 = dbInfo1.getProperties();
- Map<String, String> refAddr = new HashMap<String, String>();
- refAddr.put("driverClassName", dbInfo.getDriver());
- refAddr.put("url", dbInfo.getUrl());
- refAddr.put("username", dbInfo.getUsername());
- refAddr.put("password", dbInfo.getPassword());
+ assertEquals(connProps.get("driverClassName"), connProps1.get("driverClassName"));
+ assertEquals(connProps.get("password"), connProps1.get("password"));
+ assertEquals(connProps.get("url"), connProps1.get("url"));
+ assertEquals(connProps.get("username"), connProps1.get("username"));
+ Map<String, String> refAddr = dbInfo.getProperties();
+
initContext.bind("testjdbcjcr", "javax.sql.DataSource", "org.apache.commons.dbcp.BasicDataSourceFactory", null,
refAddr);
@@ -125,11 +123,7 @@
{
DBConnectionInfo dbInfo = dbCreator.createDatabase("testdb_" + threadNumber);
- Map<String, String> refAddr = new HashMap<String, String>();
- refAddr.put("driverClassName", dbInfo.getDriver());
- refAddr.put("url", dbInfo.getUrl());
- refAddr.put("username", dbInfo.getUsername());
- refAddr.put("password", dbInfo.getPassword());
+ Map<String, String> refAddr = dbInfo.getProperties();
initContext.bind("testjdbcjcr_" + threadNumber, "javax.sql.DataSource",
"org.apache.commons.dbcp.BasicDataSourceFactory", null, refAddr);
13 years, 4 months
exo-jcr SVN: r3832 - in jcr/trunk: exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation and 1 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2011-01-24 05:54:51 -0500 (Mon, 24 Jan 2011)
New Revision: 3832
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java
jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/core/db-creator-service.xml
Log:
EXOJCR-1148: additional properties support added to DBCreator configuration
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-01-24 09:42:28 UTC (rev 3831)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/repository/creation/RepositoryCreationServiceImpl.java 2011-01-24 10:54:51 UTC (rev 3832)
@@ -57,6 +57,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import javax.jcr.RepositoryException;
@@ -433,6 +434,10 @@
refAddr.put("url", dbConnectionInfo.getUrl());
refAddr.put("username", dbConnectionInfo.getUsername());
refAddr.put("password", dbConnectionInfo.getPassword());
+ for (Entry<String, String> entry : dbConnectionInfo.getAdditionalProperties().entrySet())
+ {
+ refAddr.put(entry.getKey(), entry.getValue());
+ }
}
catch (DBCreatorException e)
{
@@ -523,6 +528,10 @@
refAddr.put("url", dbConnectionInfo.getUrl());
refAddr.put("username", dbConnectionInfo.getUsername());
refAddr.put("password", dbConnectionInfo.getPassword());
+ for (Entry<String, String> entry : dbConnectionInfo.getAdditionalProperties().entrySet())
+ {
+ refAddr.put(entry.getKey(), entry.getValue());
+ }
}
catch (DBCreatorException e)
{
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-01-24 09:42:28 UTC (rev 3831)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/repository/creation/TestRepositoryCreationService.java 2011-01-24 10:54:51 UTC (rev 3832)
@@ -25,6 +25,7 @@
import org.exoplatform.services.jcr.ext.backup.ExtendedBackupManager;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChain;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupConfig;
+import org.exoplatform.services.jcr.impl.core.RepositoryImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import java.io.File;
@@ -44,7 +45,7 @@
protected ExtendedBackupManager getBackupManager()
{
- return (ExtendedBackupManager) container.getComponentInstanceOfType(BackupManager.class);
+ return (ExtendedBackupManager)container.getComponentInstanceOfType(BackupManager.class);
}
public void testCreateRepository() throws Exception
@@ -54,6 +55,8 @@
File backDir = new File("target/backup");
backDir.mkdirs();
+ RepositoryImpl repository = getReposityToBackup();
+
RepositoryBackupConfig config = new RepositoryBackupConfig();
config.setRepository(repository.getName());
config.setBackupType(BackupManager.FULL_BACKUP_ONLY);
Modified: jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/core/db-creator-service.xml
===================================================================
--- jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/core/db-creator-service.xml 2011-01-24 09:42:28 UTC (rev 3831)
+++ jcr/trunk/exo.jcr.docs/exo.jcr.docs.developer/en/src/main/docbook/en-US/modules/core/db-creator-service.xml 2011-01-24 10:54:51 UTC (rev 3832)
@@ -72,6 +72,9 @@
<property name="url" value="jdbc:mysql://localhost/" />
<property name="username" value="root" />
<property name="password" value="admin" />
+ <property name="additional_property" value="value">
+ ...
+ <property name="additional_property_n" value="value">
</properties-param>
<properties-param>
<name>db-creation</name>.
@@ -86,6 +89,20 @@
<para><envar>db-connection</envar> properties section contains parameters
needed for connection to database server</para>
+ <para>There is four reserved and mandatory properties
+ <emphasis>driverClassName</emphasis>, <emphasis>url</emphasis>,
+ <emphasis>username</emphasis> and <emphasis>password</emphasis>. But
+ db-connection may contain additonal properties.</para>
+
+ <para>For example, next additional proprites allows reconnect to MySQL
+ database when connection was refused:<programlisting> <properties-param>
+ <name>db-connection</name>
+ ...
+ <property name="validationQuery" value="select 1"/>
+ <property name="testOnReturn" value="true"/>
+ ...
+ </properties-param></programlisting></para>
+
<para><envar>db-creation</envar> properties section contains paramaters
for database creation using DDL script:</para>
13 years, 4 months
exo-jcr SVN: r3831 - core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2011-01-24 04:42:28 -0500 (Mon, 24 Jan 2011)
New Revision: 3831
Modified:
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java
core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
Log:
EXOJCR-1148: additional properties support added to DBCreator configuration
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java 2011-01-21 16:36:06 UTC (rev 3830)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java 2011-01-24 09:42:28 UTC (rev 3831)
@@ -18,6 +18,8 @@
*/
package org.exoplatform.services.database.creator;
+import java.util.Map;
+
/**
* Class contains needed database connection information.
*
@@ -46,6 +48,8 @@
*/
private final String password;
+ private final Map<String, String> additionalProperties;
+
/**
* DBConnectionInfo constructor.
*
@@ -60,10 +64,31 @@
*/
public DBConnectionInfo(String driver, String url, String username, String password)
{
+ this(driver, url, username, password, null);
+ }
+
+ /**
+ * DBConnectionInfo constructor.
+ *
+ * @param driver
+ * driver class name
+ * @param url
+ * db connection url
+ * @param username
+ * db connection user name
+ * @param password
+ * user's password
+ * @param additionalProperties
+ * additonal connection properties
+ */
+ public DBConnectionInfo(String driver, String url, String username, String password,
+ Map<String, String> additionalProperties)
+ {
this.driver = driver;
this.url = url;
this.username = username;
this.password = password;
+ this.additionalProperties = additionalProperties;
}
/**
@@ -98,4 +123,8 @@
return password;
}
+ public Map<String, String> getAdditionalProperties()
+ {
+ return additionalProperties;
+ }
}
Modified: core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java
===================================================================
--- core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-01-21 16:36:06 UTC (rev 3830)
+++ core/trunk/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java 2011-01-24 09:42:28 UTC (rev 3831)
@@ -23,6 +23,7 @@
import org.exoplatform.container.configuration.ConfigurationException;
import org.exoplatform.container.xml.InitParams;
import org.exoplatform.container.xml.PropertiesParam;
+import org.exoplatform.container.xml.Property;
import java.io.IOException;
import java.io.InputStream;
@@ -32,6 +33,9 @@
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
/**
* @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy Bazko</a>
@@ -96,6 +100,11 @@
protected final String dbPassword;
/**
+ * Additional connection properties.
+ */
+ protected final Map<String, String> additionalProperties;
+
+ /**
* DBCreator constructor.
*
* @param params
@@ -137,6 +146,24 @@
}
this.internal_logon = prop.getProperty("internal_logon");
+
+ // Store additional properties into map
+ Iterator<Property> pit = prop.getPropertyIterator();
+
+ additionalProperties = new HashMap<String, String>();
+
+ while (pit.hasNext())
+ {
+ Property p = pit.next();
+ String name = p.getName();
+ if (name.equalsIgnoreCase("driverClassName") || name.equalsIgnoreCase("url")
+ || name.equalsIgnoreCase("username") || name.equalsIgnoreCase("password")
+ || name.equalsIgnoreCase("internal_logon"))
+ {
+ continue;
+ }
+ additionalProperties.put(name, p.getValue());
+ }
}
else
{
@@ -380,7 +407,7 @@
dbUrl = dbUrl + (dbUrl.endsWith("/") ? "" : "/") + dbName;
}
- return new DBConnectionInfo(driver, dbUrl, dbUserName, dbPassword);
+ return new DBConnectionInfo(driver, dbUrl, dbUserName, dbPassword, additionalProperties);
}
/**
13 years, 4 months
exo-jcr SVN: r3830 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2011-01-21 11:36:06 -0500 (Fri, 21 Jan 2011)
New Revision: 3830
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java
Log:
EXOJCR-1164
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java 2011-01-21 14:29:17 UTC (rev 3829)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java 2011-01-21 16:36:06 UTC (rev 3830)
@@ -179,6 +179,17 @@
return classes;
}
+ /**
+ * Get URLs of classes (stored in JCR only) required to compile sources
+ * <code>files</code>. Result array includes URLs of <code>files</code> plus
+ * URLs of other required sources if they can be found in class-path.
+ *
+ * @param sources additional Groovy source location that should be added in
+ * class-path when analyze <code>files</code>
+ * @param files set of sources for analyzing
+ * @return URLs
+ * @throws IOException if any i/o errors occurs
+ */
public URL[] getDependencies(final SourceFolder[] sources, final SourceFile[] files) throws IOException
{
try
13 years, 5 months
exo-jcr SVN: r3829 - ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2011-01-21 09:29:17 -0500 (Fri, 21 Jan 2011)
New Revision: 3829
Modified:
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/GroovyJaxrsPublisher.java
Log:
EXOJCR-1171
Modified: ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/GroovyJaxrsPublisher.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/GroovyJaxrsPublisher.java 2011-01-21 14:28:32 UTC (rev 3828)
+++ ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/groovy/GroovyJaxrsPublisher.java 2011-01-21 14:29:17 UTC (rev 3829)
@@ -94,7 +94,7 @@
protected final Map<ResourceId, String> resources = Collections.synchronizedMap(new HashMap<ResourceId, String>());
- protected GroovyJaxrsPublisher(ResourceBinder binder, GroovyScriptInstantiator instantiator,
+ public GroovyJaxrsPublisher(ResourceBinder binder, GroovyScriptInstantiator instantiator,
GroovyClassLoaderProvider classLoaderProvider)
{
this.binder = binder;
13 years, 5 months
exo-jcr SVN: r3828 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy.
by do-not-reply@jboss.org
Author: aparfonov
Date: 2011-01-21 09:28:32 -0500 (Fri, 21 Jan 2011)
New Revision: 3828
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java
Log:
EXOJCR-1171
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java 2011-01-21 08:23:40 UTC (rev 3827)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/script/groovy/JcrGroovyCompiler.java 2011-01-21 14:28:32 UTC (rev 3828)
@@ -58,7 +58,7 @@
protected List<GroovyScriptAddRepoPlugin> addRepoPlugins;
- protected JcrGroovyCompiler(JcrGroovyClassLoaderProvider classLoaderProvider)
+ public JcrGroovyCompiler(JcrGroovyClassLoaderProvider classLoaderProvider)
{
this.classLoaderProvider = classLoaderProvider;
}
13 years, 5 months
exo-jcr SVN: r3827 - jcr/trunk/packaging/module/src/main/javascript.
by do-not-reply@jboss.org
Author: dkuleshov
Date: 2011-01-21 03:23:40 -0500 (Fri, 21 Jan 2011)
New Revision: 3827
Modified:
jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js
Log:
EXOJCR-1169: removed unnecessary jar
Modified: jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js
===================================================================
--- jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js 2011-01-21 08:05:23 UTC (rev 3826)
+++ jcr/trunk/packaging/module/src/main/javascript/jcr.packaging.module.js 2011-01-21 08:23:40 UTC (rev 3827)
@@ -22,12 +22,12 @@
addDependency(new Project("jcr", "jcr", "jar", "1.0")).
addDependency(new Project("concurrent", "concurrent", "jar", "1.3.4")).
addDependency(new Project("jgroups", "jgroups", "jar", "2.6.13.GA")).
- addDependency(new Project("stax", "stax-api", "jar", "1.0")).
-// addDependency(new Project("stax", "stax", "jar", "1.2.0")).
- addDependency(new Project("org.jboss.cache","jbosscache-core","jar","3.2.6.GA")).
- addDependency(new Project("jboss.jbossts","jbossjts","jar","4.6.1.GA")).
- addDependency(new Project("jboss.jbossts","jbossts-common","jar","4.6.1.GA")).
- addDependency(new Project("org.apache.ws.commons","ws-commons-util","jar","1.0.1")).
+// addDependency(new Project("stax", "stax-api", "jar", "1.0")).
+// addDependency(new Project("stax", "stax", "jar", "1.2.0")).
+ addDependency(new Project("org.jboss.cache","jbosscache-core","jar","3.2.6.GA")).
+ addDependency(new Project("jboss.jbossts","jbossjts","jar","4.6.1.GA")).
+ addDependency(new Project("jboss.jbossts","jbossts-common","jar","4.6.1.GA")).
+ addDependency(new Project("org.apache.ws.commons","ws-commons-util","jar","1.0.1")).
addDependency(new Project("org.apache.lucene", "lucene-core", "jar", "2.4.1")).
addDependency(new Project("org.apache.lucene", "lucene-spellchecker", "jar", "2.4.1")).
addDependency(new Project("org.apache.lucene", "lucene-memory", "jar", "2.4.1"));
13 years, 5 months