Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-19 08:22:04 +0000
committerEike Stepper2012-07-19 08:22:04 +0000
commit1460904fd3c193ffaf809913b2983a400fce9d94 (patch)
tree72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.emf.cdo.examples.server
parent5f360965ae87478e0681899bf310a210cafc2c44 (diff)
downloadcdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.examples.server')
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.core.resources.prefs6
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.server/copyright.txt14
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.server/plugin.properties22
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/internal/server/OM.java116
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/DemoConfiguration.java582
5 files changed, 370 insertions, 370 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.core.resources.prefs
index 9df1118a0e..2401f2bea1 100644
--- a/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.core.resources.prefs
+++ b/plugins/org.eclipse.emf.cdo.examples.server/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
-#Mon Jul 04 12:54:39 CEST 2011
-eclipse.preferences.version=1
-encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
+#Mon Jul 04 12:54:39 CEST 2011
+eclipse.preferences.version=1
+encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
diff --git a/plugins/org.eclipse.emf.cdo.examples.server/copyright.txt b/plugins/org.eclipse.emf.cdo.examples.server/copyright.txt
index 8f6328980e..0a0f67e6d7 100644
--- a/plugins/org.eclipse.emf.cdo.examples.server/copyright.txt
+++ b/plugins/org.eclipse.emf.cdo.examples.server/copyright.txt
@@ -1,8 +1,8 @@
-Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
+Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
Eike Stepper - initial API and implementation \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.examples.server/plugin.properties b/plugins/org.eclipse.emf.cdo.examples.server/plugin.properties
index 1521ad266f..fb248bbac5 100644
--- a/plugins/org.eclipse.emf.cdo.examples.server/plugin.properties
+++ b/plugins/org.eclipse.emf.cdo.examples.server/plugin.properties
@@ -1,11 +1,11 @@
-# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Eike Stepper - initial API and implementation
-
-pluginName = CDO Model Repository Examples Server
-providerName = Eclipse Modeling Project
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Eike Stepper - initial API and implementation
+
+pluginName = CDO Model Repository Examples Server
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/internal/server/OM.java b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/internal/server/OM.java
index 595ee47a41..483e65acb6 100644
--- a/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/internal/server/OM.java
+++ b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/internal/server/OM.java
@@ -1,58 +1,58 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.examples.internal.server;
-
-import org.eclipse.emf.cdo.examples.server.DemoServer;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.examples.server"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
-
- @Override
- protected void doStart() throws Exception
- {
- DemoServer.INSTANCE.activate();
- }
-
- @Override
- protected void doStop() throws Exception
- {
- DemoServer.INSTANCE.deactivate();
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.examples.internal.server;
+
+import org.eclipse.emf.cdo.examples.server.DemoServer;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Eike Stepper
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.emf.cdo.examples.server"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+
+ @Override
+ protected void doStart() throws Exception
+ {
+ DemoServer.INSTANCE.activate();
+ }
+
+ @Override
+ protected void doStop() throws Exception
+ {
+ DemoServer.INSTANCE.deactivate();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/DemoConfiguration.java b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/DemoConfiguration.java
index 3064f68e75..a8b9a202a4 100644
--- a/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/DemoConfiguration.java
+++ b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/DemoConfiguration.java
@@ -1,291 +1,291 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.examples.server;
-
-import org.eclipse.emf.cdo.server.CDOServerUtil;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.db.CDODBUtil;
-import org.eclipse.emf.cdo.server.db.IDBStore;
-import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
-
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-import org.eclipse.net4j.signal.ISignalProtocol;
-import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.container.ContainerEventAdapter;
-import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.container.IPluginContainer;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.security.IUserManager;
-import org.eclipse.net4j.util.security.UserManager;
-
-import org.h2.jdbcx.JdbcDataSource;
-
-import javax.sql.DataSource;
-
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-
-/**
- * @author Eike Stepper
- */
-public class DemoConfiguration extends Lifecycle
-{
- public static final int NAME_LENGTH = 10;
-
- private static final String NAME_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
-
- private Mode mode = Mode.NORMAL;
-
- private String[] userIDs;
-
- private transient String name;
-
- private transient InternalRepository repository;
-
- private DemoUserManager userManager;
-
- private transient long lastAccess = System.currentTimeMillis();
-
- DemoConfiguration(Mode mode, String[] userIDs)
- {
- this.mode = mode;
- if (userIDs != null)
- {
- if (userIDs.length != 0)
- {
- if (StringUtil.isEmpty(userIDs[0]))
- {
- userIDs = null;
- }
- }
- }
-
- this.userIDs = userIDs;
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public String[] getUserIDs()
- {
- return userIDs;
- }
-
- public String getName()
- {
- return name;
- }
-
- public IRepository getRepository()
- {
- return repository;
- }
-
- public Map<String, char[]> getUsers()
- {
- if (userManager == null)
- {
- return Collections.emptyMap();
- }
-
- return userManager.getUsers();
- }
-
- public synchronized long getTimeoutMillis()
- {
- long idleTime = System.currentTimeMillis() - lastAccess;
- long time = DemoServer.MAX_IDLE_MILLIS - idleTime;
- if (time < 0)
- {
- time = 0;
- }
-
- return time;
- }
-
- public String formatTimeoutMinutes()
- {
- return MessageFormat.format("{0,time,mm:ss}", getTimeoutMillis());
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- name = createRandomName();
-
- IDBStore store = createStore();
-
- Map<String, String> props = new HashMap<String, String>();
- props.put(IRepository.Props.OVERRIDE_UUID, ""); // Use repo name
- props.put(IRepository.Props.SUPPORTING_AUDITS, mode == Mode.NORMAL ? "false" : "true");
- props.put(IRepository.Props.SUPPORTING_BRANCHES, mode == Mode.BRANCHING ? "true" : "false");
-
- repository = (InternalRepository)CDOServerUtil.createRepository(name, store, props);
-
- InternalSessionManager sessionManager = createSessionManager();
-
- if (userIDs != null)
- {
- IUserManager userManager = createUserManager();
- sessionManager.setUserManager(userManager);
- }
-
- CDOServerUtil.addRepository(IPluginContainer.INSTANCE, repository);
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- if (repository != null)
- {
- File folder = new File(new File("databases"), repository.getName());
-
- LifecycleUtil.deactivate(repository);
- repository = null;
-
- IOUtil.delete(folder);
- }
- }
-
- protected String createRandomName()
- {
- return createRandomString(NAME_LENGTH, NAME_ALPHABET);
- }
-
- protected IDBStore createStore()
- {
- IMappingStrategy mappingStrategy = createMappingStrategy();
- IDBAdapter dbAdapter = DBUtil.getDBAdapter("h2");
- IDBConnectionProvider dbConnectionProvider = DBUtil.createConnectionProvider(createDataSource());
- IDBStore store = CDODBUtil.createStore(mappingStrategy, dbAdapter, dbConnectionProvider);
- return store;
- }
-
- protected IMappingStrategy createMappingStrategy()
- {
- switch (mode)
- {
- case NORMAL:
- return CDODBUtil.createHorizontalMappingStrategy(false, false);
- case AUDITING:
- return CDODBUtil.createHorizontalMappingStrategy(true, false);
- case BRANCHING:
- return CDODBUtil.createHorizontalMappingStrategy(true, true);
- default:
- throw new IllegalStateException("Invalid mode: " + mode);
- }
- }
-
- protected DataSource createDataSource()
- {
- JdbcDataSource dataSource = new JdbcDataSource();
- dataSource.setURL("jdbc:h2:databases/" + name + "/h2test");
- return dataSource;
- }
-
- protected InternalSessionManager createSessionManager()
- {
- InternalSessionManager sessionManager = (InternalSessionManager)CDOServerUtil.createSessionManager();
- repository.setSessionManager(sessionManager);
- sessionManager.addListener(new ContainerEventAdapter<ISession>()
- {
- @Override
- protected void onAdded(IContainer<ISession> container, ISession session)
- {
- ISignalProtocol<?> protocol = (ISignalProtocol<?>)session.getProtocol();
- if (protocol != null)
- {
- protocol.addListener(new IListener()
- {
- public void notifyEvent(IEvent event)
- {
- synchronized (DemoConfiguration.this)
- {
- lastAccess = System.currentTimeMillis();
- }
- }
- });
- }
- }
- });
-
- return sessionManager;
- }
-
- protected IUserManager createUserManager()
- {
- userManager = new DemoUserManager();
- for (int i = 0; i < userIDs.length; i++)
- {
- String userID = userIDs[i];
- userManager.addUser(userID, ("pw" + (i + 1)).toCharArray());
- }
-
- userManager.activate();
- return userManager;
- }
-
- public static String createRandomString(int length, String alphabet)
- {
- Random random = new Random(System.currentTimeMillis());
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < length; i++)
- {
- int pos = random.nextInt(alphabet.length());
- builder.append(alphabet.charAt(pos));
- }
-
- return builder.toString();
- }
-
- public static String createRandomString(int length)
- {
- return createRandomString(length, NAME_ALPHABET);
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class DemoUserManager extends UserManager
- {
- public DemoUserManager()
- {
- }
-
- public Map<String, char[]> getUsers()
- {
- return users;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public enum Mode
- {
- NORMAL, AUDITING, BRANCHING
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.examples.server;
+
+import org.eclipse.emf.cdo.server.CDOServerUtil;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.server.db.CDODBUtil;
+import org.eclipse.emf.cdo.server.db.IDBStore;
+import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
+
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnectionProvider;
+import org.eclipse.net4j.signal.ISignalProtocol;
+import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.container.ContainerEventAdapter;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.container.IPluginContainer;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.security.IUserManager;
+import org.eclipse.net4j.util.security.UserManager;
+
+import org.h2.jdbcx.JdbcDataSource;
+
+import javax.sql.DataSource;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * @author Eike Stepper
+ */
+public class DemoConfiguration extends Lifecycle
+{
+ public static final int NAME_LENGTH = 10;
+
+ private static final String NAME_ALPHABET = "abcdefghijklmnopqrstuvwxyz";
+
+ private Mode mode = Mode.NORMAL;
+
+ private String[] userIDs;
+
+ private transient String name;
+
+ private transient InternalRepository repository;
+
+ private DemoUserManager userManager;
+
+ private transient long lastAccess = System.currentTimeMillis();
+
+ DemoConfiguration(Mode mode, String[] userIDs)
+ {
+ this.mode = mode;
+ if (userIDs != null)
+ {
+ if (userIDs.length != 0)
+ {
+ if (StringUtil.isEmpty(userIDs[0]))
+ {
+ userIDs = null;
+ }
+ }
+ }
+
+ this.userIDs = userIDs;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public String[] getUserIDs()
+ {
+ return userIDs;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public IRepository getRepository()
+ {
+ return repository;
+ }
+
+ public Map<String, char[]> getUsers()
+ {
+ if (userManager == null)
+ {
+ return Collections.emptyMap();
+ }
+
+ return userManager.getUsers();
+ }
+
+ public synchronized long getTimeoutMillis()
+ {
+ long idleTime = System.currentTimeMillis() - lastAccess;
+ long time = DemoServer.MAX_IDLE_MILLIS - idleTime;
+ if (time < 0)
+ {
+ time = 0;
+ }
+
+ return time;
+ }
+
+ public String formatTimeoutMinutes()
+ {
+ return MessageFormat.format("{0,time,mm:ss}", getTimeoutMillis());
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ name = createRandomName();
+
+ IDBStore store = createStore();
+
+ Map<String, String> props = new HashMap<String, String>();
+ props.put(IRepository.Props.OVERRIDE_UUID, ""); // Use repo name
+ props.put(IRepository.Props.SUPPORTING_AUDITS, mode == Mode.NORMAL ? "false" : "true");
+ props.put(IRepository.Props.SUPPORTING_BRANCHES, mode == Mode.BRANCHING ? "true" : "false");
+
+ repository = (InternalRepository)CDOServerUtil.createRepository(name, store, props);
+
+ InternalSessionManager sessionManager = createSessionManager();
+
+ if (userIDs != null)
+ {
+ IUserManager userManager = createUserManager();
+ sessionManager.setUserManager(userManager);
+ }
+
+ CDOServerUtil.addRepository(IPluginContainer.INSTANCE, repository);
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ if (repository != null)
+ {
+ File folder = new File(new File("databases"), repository.getName());
+
+ LifecycleUtil.deactivate(repository);
+ repository = null;
+
+ IOUtil.delete(folder);
+ }
+ }
+
+ protected String createRandomName()
+ {
+ return createRandomString(NAME_LENGTH, NAME_ALPHABET);
+ }
+
+ protected IDBStore createStore()
+ {
+ IMappingStrategy mappingStrategy = createMappingStrategy();
+ IDBAdapter dbAdapter = DBUtil.getDBAdapter("h2");
+ IDBConnectionProvider dbConnectionProvider = DBUtil.createConnectionProvider(createDataSource());
+ IDBStore store = CDODBUtil.createStore(mappingStrategy, dbAdapter, dbConnectionProvider);
+ return store;
+ }
+
+ protected IMappingStrategy createMappingStrategy()
+ {
+ switch (mode)
+ {
+ case NORMAL:
+ return CDODBUtil.createHorizontalMappingStrategy(false, false);
+ case AUDITING:
+ return CDODBUtil.createHorizontalMappingStrategy(true, false);
+ case BRANCHING:
+ return CDODBUtil.createHorizontalMappingStrategy(true, true);
+ default:
+ throw new IllegalStateException("Invalid mode: " + mode);
+ }
+ }
+
+ protected DataSource createDataSource()
+ {
+ JdbcDataSource dataSource = new JdbcDataSource();
+ dataSource.setURL("jdbc:h2:databases/" + name + "/h2test");
+ return dataSource;
+ }
+
+ protected InternalSessionManager createSessionManager()
+ {
+ InternalSessionManager sessionManager = (InternalSessionManager)CDOServerUtil.createSessionManager();
+ repository.setSessionManager(sessionManager);
+ sessionManager.addListener(new ContainerEventAdapter<ISession>()
+ {
+ @Override
+ protected void onAdded(IContainer<ISession> container, ISession session)
+ {
+ ISignalProtocol<?> protocol = (ISignalProtocol<?>)session.getProtocol();
+ if (protocol != null)
+ {
+ protocol.addListener(new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ synchronized (DemoConfiguration.this)
+ {
+ lastAccess = System.currentTimeMillis();
+ }
+ }
+ });
+ }
+ }
+ });
+
+ return sessionManager;
+ }
+
+ protected IUserManager createUserManager()
+ {
+ userManager = new DemoUserManager();
+ for (int i = 0; i < userIDs.length; i++)
+ {
+ String userID = userIDs[i];
+ userManager.addUser(userID, ("pw" + (i + 1)).toCharArray());
+ }
+
+ userManager.activate();
+ return userManager;
+ }
+
+ public static String createRandomString(int length, String alphabet)
+ {
+ Random random = new Random(System.currentTimeMillis());
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < length; i++)
+ {
+ int pos = random.nextInt(alphabet.length());
+ builder.append(alphabet.charAt(pos));
+ }
+
+ return builder.toString();
+ }
+
+ public static String createRandomString(int length)
+ {
+ return createRandomString(length, NAME_ALPHABET);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class DemoUserManager extends UserManager
+ {
+ public DemoUserManager()
+ {
+ }
+
+ public Map<String, char[]> getUsers()
+ {
+ return users;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public enum Mode
+ {
+ NORMAL, AUDITING, BRANCHING
+ }
+}

Back to the top