true
if this view will notify its {@link IListener listeners} about changes to the
+ * {@link CDOLockState lock states} of the objects in this view (due to lock operations in other views),
+ * false
otherwise.
+ *
+ * @see CDOLockState
+ */
+ public boolean isLockNotificationEnabled();
+
+ /**
+ * Specifies whether this view will notify its {@link IListener listeners} about changes to the {@link CDOLockState
+ * lock states} of the objects in this view (due to lock operations in other views), or not.
+ *
+ * @see CDOLockState
+ */
+ public void setLockNotificationEnabled(boolean enabled);
+
+ /**
+ * @author Caspar De Groot
+ */
+ public interface LockNotificationEvent extends IOptionsEvent
+ {
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfo.java
index 0307719d42..b3a55b4833 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfo.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfo.java
@@ -13,6 +13,8 @@ package org.eclipse.emf.cdo.common.lock;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+
/**
* Represents a change in the lock state of a set of objects. Instances are meant to be sent from the server to the
* client for the purpose of notifying the latter.
@@ -50,6 +52,11 @@ public interface CDOLockChangeInfo extends CDOBranchPoint
*/
public Operation getOperation();
+ /**
+ * @return the type of locks that were affected by the lock operation
+ */
+ public LockType getLockType();
+
/**
* Enumerates the possible locking operations.
*
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfoHandler.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfoHandler.java
new file mode 100644
index 0000000000..118f973516
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfoHandler.java
@@ -0,0 +1,20 @@
+/**
+ * Copyright (c) 2004 - 2011 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:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.common.lock;
+
+/**
+ * @author Caspar De Groot
+ * @since 4.1
+ */
+public interface CDOLockChangeInfoHandler
+{
+ public void handleLockChangeInfo(CDOLockChangeInfo lockChangeInfo);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockOwner.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockOwner.java
index 012fc15117..b5b42d29ff 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockOwner.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockOwner.java
@@ -31,25 +31,7 @@ public interface CDOLockOwner
*/
public int getViewID();
- /**
- * A constant to represent on the client-side that a lock's owner cannot be represented as a viewID-sessionID pair.
- */
- public static final CDOLockOwner UNKNOWN = new CDOLockOwner()
- {
- public int getViewID()
- {
- return 0;
- }
-
- public int getSessionID()
- {
- return 0;
- }
+ public String getDurableLockingID();
- @Override
- public String toString()
- {
- return CDOLockOwner.class.getSimpleName() + ".UNKNOWN";
- }
- };
+ public boolean isDurableView();
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java
index d36d9078b6..3250f5adfa 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java
@@ -13,15 +13,25 @@ package org.eclipse.emf.cdo.common.lock;
import org.eclipse.emf.cdo.common.CDOCommonSession;
import org.eclipse.emf.cdo.common.CDOCommonView;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
import org.eclipse.emf.cdo.internal.common.lock.CDOLockChangeInfoImpl;
import org.eclipse.emf.cdo.internal.common.lock.CDOLockOwnerImpl;
import org.eclipse.emf.cdo.internal.common.lock.CDOLockStateImpl;
+import org.eclipse.emf.cdo.internal.common.lock.CDOLockAreaImpl;
import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.HexUtil;
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState;
+import java.util.Map;
+import java.util.Random;
+
/**
* Various static methods that may help with classes related to CDO locks.
*
@@ -47,9 +57,23 @@ public final class CDOLockUtil
for (CDOCommonView view : lockState.getReadLockOwners())
{
- int sessionID = view.getSession().getSessionID();
- int viewID = view.getViewID();
- CDOLockOwner owner = new CDOLockOwnerImpl(sessionID, viewID);
+ String durableLockingID = view.getDurableLockingID();
+ int sessionID, viewID;
+ CDOCommonSession session = view.getSession();
+ boolean isDurableView = session == null;
+ if (isDurableView)
+ {
+ // TODO (CD) Use some symbolic constants here?
+ sessionID = 0;
+ viewID = 0;
+ }
+ else
+ {
+ sessionID = session.getSessionID();
+ viewID = view.getViewID();
+ }
+
+ CDOLockOwner owner = new CDOLockOwnerImpl(sessionID, viewID, durableLockingID, isDurableView);
cdoLockState.addReadLockOwner(owner);
}
@@ -73,25 +97,54 @@ public final class CDOLockUtil
public static CDOLockOwner createLockOwner(CDOCommonView view)
{
CDOCommonSession session = view.getSession();
+ String durableLockingID = view.getDurableLockingID();
if (session != null)
{
int sessionID = session.getSessionID();
int viewID = view.getViewID();
- return new CDOLockOwnerImpl(sessionID, viewID);
+ return new CDOLockOwnerImpl(sessionID, viewID, durableLockingID, false);
}
- return CDOLockOwner.UNKNOWN;
+
+ CheckUtil.checkNull(durableLockingID, "durableLockingID");
+ return new CDOLockOwnerImpl(0, 0, durableLockingID, true); // TODO (CD) Symbolic constants?
}
public static CDOLockChangeInfo createLockChangeInfo(long timestamp, CDOLockOwner lockOwner, CDOBranch branch,
- Operation op, CDOLockState[] cdoLockStates)
+ Operation op, LockType lockType, CDOLockState[] cdoLockStates)
{
- return new CDOLockChangeInfoImpl(branch.getPoint(timestamp), lockOwner, cdoLockStates, op);
+ return new CDOLockChangeInfoImpl(branch.getPoint(timestamp), lockOwner, cdoLockStates, op, lockType);
}
public static CDOLockChangeInfo createLockChangeInfo(long timestamp, CDOCommonView view, CDOBranch viewedBranch,
- Operation op, CDOLockState[] cdoLockStates)
+ Operation op, LockType lockType, CDOLockState[] cdoLockStates)
{
CDOLockOwner lockOwner = createLockOwner(view);
- return createLockChangeInfo(timestamp, lockOwner, viewedBranch, op, cdoLockStates);
+ return createLockChangeInfo(timestamp, lockOwner, viewedBranch, op, lockType, cdoLockStates);
+ }
+
+ public static LockArea createLockArea(String durableLockingID, String userID, CDOBranchPoint branchPoint,
+ boolean readOnly, Mapnull
.
@@ -52,6 +52,11 @@ public interface IDurableLockingManager
*/
public interface LockArea extends CDOBranchPoint
{
+ /**
+ * @since 4.1
+ */
+ public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32;
+
public String getDurableLockingID();
public String getUserID();
@@ -60,6 +65,11 @@ public interface IDurableLockingManager
public Mapnull
if the view was remote.
+ */
+ public CDOView getSender();
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOLocksChangedEvent.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOLocksChangedEvent.java
deleted file mode 100644
index 904dabbaaf..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOLocksChangedEvent.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Copyright (c) 2004 - 2011 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:
- * Caspar De Groot - initial API and implementation
- */
-package org.eclipse.emf.cdo.view;
-
-import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
-
-/**
- * A {@link CDOViewEvent view event} fired when lock notifications are being received from a repository.
- * {@link CDOView.Options#setLockNotificationEnabled(boolean)} must be enabled for this event to be fired.
- *
- * @author Caspar De Groot
- * @since 4.1
- */
-public interface CDOLocksChangedEvent extends CDOViewEvent, CDOLockChangeInfo
-{
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
index 4d74a8f3c2..100d1a4f65 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
@@ -21,7 +21,6 @@ import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.util.CDOException;
import org.eclipse.emf.cdo.eresource.CDOResource;
@@ -35,10 +34,7 @@ import org.eclipse.emf.cdo.util.ReadOnlyException;
import org.eclipse.net4j.util.collection.CloseableIterator;
import org.eclipse.net4j.util.concurrent.IRWLockManager;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.event.INotifier;
-import org.eclipse.net4j.util.options.IOptions;
-import org.eclipse.net4j.util.options.IOptionsContainer;
import org.eclipse.net4j.util.options.IOptionsEvent;
import org.eclipse.net4j.util.ref.ReferenceType;
@@ -76,7 +72,7 @@ import java.util.Set;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier, IOptionsContainer
+public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier
{
/**
* Returns the {@link CDOSession session} this view was opened by.
@@ -406,7 +402,7 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier, IOption
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
- public interface Options extends IOptions
+ public interface Options extends org.eclipse.emf.cdo.common.CDOCommonView.Options
{
/**
* Returns the {@link CDOView view} of this options object.
@@ -467,27 +463,6 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier, IOption
*/
public void setInvalidationNotificationEnabled(boolean enabled);
- /**
- * Returns true
if this view will notify its {@link IListener listeners} about changes to the
- * {@link CDOLockState lock states} of the objects in this view (due to lock operations in other views),
- * false
otherwise.
- *
- * @see CDOLocksChangedEvent
- * @see CDOLockState
- * @since 4.1
- */
- public boolean isLockNotificationEnabled();
-
- /**
- * Specifies whether this view will notify its {@link IListener listeners} about changes to the {@link CDOLockState
- * lock states} of the objects in this view (due to lock operations in other views), or not.
- *
- * @see CDOLocksChangedEvent
- * @see CDOLockState
- * @since 4.1
- */
- public void setLockNotificationEnabled(boolean enabled);
-
/**
* Returns the current set of {@link CDOAdapterPolicy change subscription policies}.
*
@@ -668,14 +643,6 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier, IOption
{
}
- /**
- * @author Caspar De Groot
- * @since 4.1
- */
- public interface LockNotificationEvent extends IOptionsEvent
- {
- }
-
/**
* An {@link IOptionsEvent options event} fired from view {@link CDOView#options() options} when the
* {@link Options#setRevisionPrefetchingPolicy(CDORevisionPrefetchingPolicy) revision prefetching policy} option has
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewLocksChangedEvent.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewLocksChangedEvent.java
new file mode 100644
index 0000000000..8bdb7d8005
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewLocksChangedEvent.java
@@ -0,0 +1,25 @@
+/**
+ * Copyright (c) 2004 - 2011 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:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.view;
+
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
+
+/**
+ * @author Caspar De Groot
+ * @since 4.1
+ */
+public interface CDOViewLocksChangedEvent extends CDOViewEvent, CDOLockChangeInfo
+{
+ /**
+ * Returns the view that caused the lock changes if this view is local, or null
if the view was remote.
+ */
+ public CDOView getSender();
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
index 607d3855fe..3bb1caf936 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionConfigurationImpl.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.internal.cdo.session;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
@@ -43,6 +44,8 @@ public abstract class CDOSessionConfigurationImpl extends Notifier implements In
private PassiveUpdateMode passiveUpdateMode = PassiveUpdateMode.INVALIDATIONS;
+ private LockNotificationMode lockNotificationMode = LockNotificationMode.IF_REQUIRED_BY_VIEWS;
+
private CDOAuthenticator authenticator = new CDOAuthenticatorImpl();
private CDOSession.ExceptionHandler exceptionHandler;
@@ -120,6 +123,22 @@ public abstract class CDOSessionConfigurationImpl extends Notifier implements In
this.passiveUpdateMode = passiveUpdateMode;
}
+ public LockNotificationMode getLockNotificationMode()
+ {
+ return lockNotificationMode;
+ }
+
+ public void setLockNotificationMode(LockNotificationMode lockNotificationMode)
+ {
+ checkNotOpen();
+ uncheckedSetLockNotificationMode(lockNotificationMode);
+ }
+
+ protected void uncheckedSetLockNotificationMode(LockNotificationMode lockNotificationMode)
+ {
+ this.lockNotificationMode = lockNotificationMode;
+ }
+
public CDOAuthenticator getAuthenticator()
{
return authenticator;
@@ -272,6 +291,7 @@ public abstract class CDOSessionConfigurationImpl extends Notifier implements In
{
session.options().setPassiveUpdateEnabled(passiveUpdateEnabled);
session.options().setPassiveUpdateMode(passiveUpdateMode);
+ session.options().setLockNotificationMode(lockNotificationMode);
session.setMainBranchLocal(mainBranchLocal);
session.setExceptionHandler(exceptionHandler);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index 0c3f04c28c..4e5b154dff 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -57,6 +57,7 @@ import org.eclipse.emf.cdo.session.CDOCollectionLoadingPolicy;
import org.eclipse.emf.cdo.session.CDORepositoryInfo;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
+import org.eclipse.emf.cdo.session.CDOSessionLocksChangedEvent;
import org.eclipse.emf.cdo.session.remote.CDORemoteSessionManager;
import org.eclipse.emf.cdo.spi.common.CDOLobStoreImpl;
import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
@@ -83,6 +84,7 @@ import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.messages.Messages;
import org.eclipse.emf.internal.cdo.object.CDOFactoryImpl;
import org.eclipse.emf.internal.cdo.session.remote.CDORemoteSessionManagerImpl;
+import org.eclipse.emf.internal.cdo.util.DefaultLocksChangedEvent;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
@@ -836,12 +838,17 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
}
}
- public void handleLockNotification(CDOLockChangeInfo lockChangeInfo)
+ public void handleLockNotification(CDOLockChangeInfo lockChangeInfo, InternalCDOView sender)
{
for (InternalCDOView view : getViews())
{
- view.handleLockNotification(lockChangeInfo);
+ if (view != sender)
+ {
+ view.handleLockNotification(sender, lockChangeInfo);
+ }
}
+
+ fireEvent(new LocksChangedEvent(sender, lockChangeInfo));
}
private void registerPackageUnits(List- // * In the case where {@link CDOObject#cdoRevision()} or {@link CDOObject#cdoState()} is called without using this - // * lock, it is not guarantee that the state didn't change immediately after. - // *
- // *
- // * if (cdoObject.cdoState() != CDOState.PROXY)
- // * {
- // * // At this point could be a proxy!
- // * cdoObject.cdoRevision();
- // * }
- // *
- // *
- // * The reason were we didn't use {@link CDOView#getLock()} is to not allow the access of that lock to the users
- // since
- // * it is very critical. Instead of giving this API to the end-users, a better API should be given in the CDOObject
- // to
- // * give them want they need.
- // */
- // public ReentrantLock getStateLock();
- //
- // /**
- // * @since 4.0
- // */
- // public Object getObjectsLock();
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWOLockManager.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWOLockManager.java
index 846e9f3e35..89e6844b5c 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWOLockManager.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/concurrent/RWOLockManager.java
@@ -40,6 +40,13 @@ public class RWOLockManager
+ * This map is a performance optimization to avoid having to scan all lock states.
+ */
private final Map";
- protected final String TEXT_4 = "
" + NL + "";
- protected final String TEXT_5 = NL + "\t
" + NL + "" + NL + "" + NL + "";
- protected final String TEXT_13 = NL;
-
- public String generate(Object argument)
- {
- final StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append(TEXT_1);
- MenuCard menuCard = (MenuCard)argument;
- stringBuffer.append(TEXT_2);
- stringBuffer.append(GastroServlet.html(menuCard.getTitle()));
- stringBuffer.append(TEXT_3);
- stringBuffer.append(GastroServlet.html(menuCard.getTitle()));
- stringBuffer.append(TEXT_4);
- for (Section section : menuCard.getSections()) {
- stringBuffer.append(TEXT_5);
- stringBuffer.append(GastroServlet.html(section.getTitle()));
- stringBuffer.append(TEXT_6);
- stringBuffer.append(GastroServlet.html(section.getText()));
- stringBuffer.append(TEXT_7);
- for (Offering offering : section.getOfferings()) {
- stringBuffer.append(TEXT_8);
- stringBuffer.append(GastroServlet.html(offering.getName()));
- stringBuffer.append(TEXT_9);
- stringBuffer.append(GastroServlet.html(offering.getDescription()));
- stringBuffer.append(TEXT_10);
- stringBuffer.append(GastroServlet.html(offering.getPrice()));
- stringBuffer.append(TEXT_11);
- }
- }
- stringBuffer.append(TEXT_12);
- stringBuffer.append(TEXT_13);
- return stringBuffer.toString();
- }
-}
+package templates;
+
+import org.gastro.inventory.*;
+import org.gastro.server.internal.web.*;
+
+public class MenuCardTemplate
+{
+ protected static String nl;
+ public static synchronized MenuCardTemplate create(String lineSeparator)
+ {
+ nl = lineSeparator;
+ MenuCardTemplate result = new MenuCardTemplate();
+ nl = null;
+ return result;
+ }
+
+ public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
+ protected final String TEXT_1 = "";
+ protected final String TEXT_2 = NL + NL + "" + NL + " " + NL + "\t";
- protected final String TEXT_6 = "
" + NL + "\t";
- protected final String TEXT_8 = NL + "\t\t";
- protected final String TEXT_7 = "
" + NL + "\t\t ";
- protected final String TEXT_9 = "
" + NL + "\t";
- protected final String TEXT_12 = NL + " ";
- protected final String TEXT_10 = " " + NL + "\t\t\t\t\t";
- protected final String TEXT_11 = " ";
+ protected final String TEXT_4 = "
" + NL + "";
+ protected final String TEXT_5 = NL + "\t
" + NL + "" + NL + "" + NL + "";
+ protected final String TEXT_13 = NL;
+
+ public String generate(Object argument)
+ {
+ final StringBuffer stringBuffer = new StringBuffer();
+ stringBuffer.append(TEXT_1);
+ MenuCard menuCard = (MenuCard)argument;
+ stringBuffer.append(TEXT_2);
+ stringBuffer.append(GastroServlet.html(menuCard.getTitle()));
+ stringBuffer.append(TEXT_3);
+ stringBuffer.append(GastroServlet.html(menuCard.getTitle()));
+ stringBuffer.append(TEXT_4);
+ for (Section section : menuCard.getSections()) {
+ stringBuffer.append(TEXT_5);
+ stringBuffer.append(GastroServlet.html(section.getTitle()));
+ stringBuffer.append(TEXT_6);
+ stringBuffer.append(GastroServlet.html(section.getText()));
+ stringBuffer.append(TEXT_7);
+ for (Offering offering : section.getOfferings()) {
+ stringBuffer.append(TEXT_8);
+ stringBuffer.append(GastroServlet.html(offering.getName()));
+ stringBuffer.append(TEXT_9);
+ stringBuffer.append(GastroServlet.html(offering.getDescription()));
+ stringBuffer.append(TEXT_10);
+ stringBuffer.append(GastroServlet.html(offering.getPrice()));
+ stringBuffer.append(TEXT_11);
+ }
+ }
+ stringBuffer.append(TEXT_12);
+ stringBuffer.append(TEXT_13);
+ return stringBuffer.toString();
+ }
+}
--
cgit v1.2.3
" + NL + "\t";
+ protected final String TEXT_6 = "
" + NL + "\t";
+ protected final String TEXT_8 = NL + "\t\t";
+ protected final String TEXT_7 = "
" + NL + "\t\t ";
+ protected final String TEXT_9 = "
" + NL + "\t";
+ protected final String TEXT_12 = NL + " ";
+ protected final String TEXT_10 = " " + NL + "\t\t\t\t\t";
+ protected final String TEXT_11 = "