001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.core.impl.model.instance.persistent;
023:
024: import org.jboss.portal.common.i18n.LocalizedString;
025: import org.jboss.portal.core.impl.model.instance.AbstractInstanceCustomization;
026: import org.jboss.portal.core.impl.model.instance.AbstractInstanceDefinition;
027: import org.jboss.portal.core.impl.model.instance.InstanceContainerContext;
028: import org.jboss.portal.portlet.PortletContext;
029:
030: /**
031: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
032: * @version $Revision: 9574 $
033: */
034: class PersistentInstanceCustomization extends
035: AbstractInstanceCustomization {
036:
037: // Persistent fields
038:
039: protected Long key;
040: protected PersistentInstanceDefinition relatedDefinition;
041: protected String customizationId;
042: protected LocalizedString displayName;
043:
044: // Runtime fields
045:
046: protected PersistentInstanceDefinition owner;
047: protected boolean persistent;
048:
049: /** Used to build transient instances. */
050: public PersistentInstanceCustomization(
051: PersistentInstanceDefinition owner, String customizationId,
052: PortletContext portletContext) {
053: if (owner == null) {
054: throw new IllegalArgumentException();
055: }
056: if (customizationId == null) {
057: throw new IllegalArgumentException();
058: }
059: if (portletContext == null) {
060: throw new IllegalArgumentException();
061: }
062:
063: //
064: this .owner = owner;
065: this .persistent = false;
066:
067: //
068: this .customizationId = customizationId;
069: this .portletRef = portletContext.getId();
070: this .state = portletContext.getState();
071: }
072:
073: /** Used by hibernate. */
074: public PersistentInstanceCustomization() {
075: this .owner = null;
076: this .persistent = true;
077: }
078:
079: public Long getKey() {
080: return key;
081: }
082:
083: public void setKey(Long key) {
084: this .key = key;
085: }
086:
087: public String getId() {
088: return owner.getInstanceId();
089: }
090:
091: public LocalizedString getDisplayName() {
092: return owner.getDisplayName();
093: }
094:
095: public void setDisplayName(LocalizedString localizedString) {
096: this .displayName = localizedString;
097: }
098:
099: public String getCustomizationId() {
100: return customizationId;
101: }
102:
103: public void setCustomizationId(String customizationId) {
104: this .customizationId = customizationId;
105: }
106:
107: public AbstractInstanceDefinition getOwner() {
108: return owner;
109: }
110:
111: public PersistentInstanceDefinition getRelatedDefinition() {
112: return relatedDefinition;
113: }
114:
115: public void setRelatedDefinition(
116: PersistentInstanceDefinition relatedDefinition) {
117: this .relatedDefinition = relatedDefinition;
118: this .owner = relatedDefinition;
119: }
120:
121: protected boolean isPersistent() {
122: return persistent;
123: }
124:
125: protected InstanceContainerContext getContainerContext() {
126: return owner.containerContext;
127: }
128: }
|