Author: julien(a)jboss.com
Date: 2007-12-19 09:12:30 -0500 (Wed, 19 Dec 2007)
New Revision: 9373
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectFactory.java
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContainer.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContext.java
Log:
introduce factory for getting implementation of model classes
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContainer.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContainer.java 2007-12-19
12:49:13 UTC (rev 9372)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContainer.java 2007-12-19
14:12:30 UTC (rev 9373)
@@ -273,9 +273,13 @@
//
if (object == null)
{
- object = createObject(structuralObject);
+ //
+ UIObjectContext context = new UIObjectContext(this, structuralObject);
//
+ object = new UIObjectFactory().createObject(context);
+
+ //
universe.put(structuralObject.getId(), object);
}
else
@@ -289,37 +293,4 @@
return object;
}
- private AbstractUIObject createObject(StructuralObject state)
- {
- Class type = state.getState().getType();
-
- //
- UIObjectContext context = new UIObjectContext(this, state);
-
- //
- if(type == UIContext.class)
- {
- return new UIContextImpl(context);
- }
- else if(type == UIPortal.class)
- {
- return new UIPortalImpl(context);
- }
- else if(type == UIPage.class)
- {
- return new UIPageImpl(context);
- }
- else if(type == UIContainer.class)
- {
- return new UIContainerImpl(context);
- }
- else if(type == UIWindow.class)
- {
- return new UIWindowImpl(context);
- }
- else
- {
- throw new AssertionError();
- }
- }
}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContext.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContext.java 2007-12-19
12:49:13 UTC (rev 9372)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectContext.java 2007-12-19
14:12:30 UTC (rev 9373)
@@ -23,6 +23,7 @@
package org.jboss.portal.presentation.impl.model.container;
import org.jboss.portal.presentation.model.state.structural.StructuralObject;
+import org.jboss.portal.presentation.model.state.structural.StructuralState;
import org.jboss.portal.presentation.model.state.StateException;
import org.jboss.portal.presentation.model.state.NoSuchStateException;
import org.jboss.portal.presentation.model.state.StaleStateException;
@@ -67,6 +68,11 @@
// Public
***********************************************************************************************************
+ public StructuralState getState()
+ {
+ return structuralObject.getState();
+ }
+
public UIContext getRoot()
{
return container.root;
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectFactory.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectFactory.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectFactory.java 2007-12-19
14:12:30 UTC (rev 9373)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.impl.model.container;
+
+import org.jboss.portal.presentation.model.UIContext;
+import org.jboss.portal.presentation.model.UIPortal;
+import org.jboss.portal.presentation.model.UIPage;
+import org.jboss.portal.presentation.model.UIContainer;
+import org.jboss.portal.presentation.model.UIWindow;
+import org.jboss.portal.presentation.impl.model.UIContextImpl;
+import org.jboss.portal.presentation.impl.model.UIPortalImpl;
+import org.jboss.portal.presentation.impl.model.UIPageImpl;
+import org.jboss.portal.presentation.impl.model.UIContainerImpl;
+import org.jboss.portal.presentation.impl.model.UIWindowImpl;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class UIObjectFactory
+{
+
+ public AbstractUIObject createObject(UIObjectContext context)
+ {
+ Class type = context.getState().getType();
+
+ //
+ if(type == UIContext.class)
+ {
+ return new UIContextImpl(context);
+ }
+ else if(type == UIPortal.class)
+ {
+ return new UIPortalImpl(context);
+ }
+ else if(type == UIPage.class)
+ {
+ return new UIPageImpl(context);
+ }
+ else if(type == UIContainer.class)
+ {
+ return new UIContainerImpl(context);
+ }
+ else if(type == UIWindow.class)
+ {
+ return new UIWindowImpl(context);
+ }
+ else
+ {
+ throw new AssertionError();
+ }
+ }
+}