diff options
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context')
10 files changed, 0 insertions, 895 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContext.java deleted file mode 100644 index b0bac6a3c..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContext.java +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.designtime.context; - -import java.util.Collections; -import java.util.Map; - -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolConstants; - -/** - * The parent of all IDTExternalContext implementations - * - * Clients must sub-class to create IDTExternalContext implementations - * - * @author cbateman - * - */ -public abstract class AbstractDTExternalContext implements IDTExternalContext -{ - - /** - * Return a map of available symbols in each of the masked scopes - * indexed by symbol name - * - * Called by {@link #getMapForScope(int)} to satify the interface. - * If null is returned {@link #getMapForScope(int)} will automatically - * return an EMPTY_MAP. - * - * @param scopeMask - * @return the map of symbols - */ - protected abstract Map<String, ISymbol> doGetMapForScope(int scopeMask); - - - public final Map<String, ISymbol> getMapForScope(final int scopeMask) - { - Map<String, ISymbol> mapForScope = doGetMapForScope(scopeMask); - - if (mapForScope == null) - { - mapForScope = Collections.EMPTY_MAP; - } - else - { - mapForScope = Collections.unmodifiableMap(mapForScope); - } - return mapForScope; - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.context.IDTExternalContext#getRequestMap() - */ - public final Map<String, ISymbol> getRequestMap() - { - return getMapForScope(ISymbolConstants.SYMBOL_SCOPE_REQUEST); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.context.IDTExternalContext#getSessionMap() - */ - public final Map<String, ISymbol> getSessionMap() - { - return getMapForScope(ISymbolConstants.SYMBOL_SCOPE_SESSION); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.context.IDTExternalContext#getApplicationMap() - */ - public final Map<String, ISymbol> getApplicationMap() - { - return getMapForScope(ISymbolConstants.SYMBOL_SCOPE_APPLICATION); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.context.IDTExternalContext#getNoneMap() - */ - public final Map<String, ISymbol> getNoneMap() - { - return getMapForScope(ISymbolConstants.SYMBOL_SCOPE_NONE); - } - - /* (non-Javadoc) - * @see org.eclipse.jst.jsf.designtime.context.IDTExternalContext#getRequestContextPath() - */ - public String getRequestContextPath() - { - // API: do we need to support default behaviour here? - return null; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContextFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContextFactory.java deleted file mode 100644 index b2fbbbf13..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractDTExternalContextFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * Super-class of all external context factories - * - * @author cbateman - * - */ -public abstract class AbstractDTExternalContextFactory -{ - /** - * @param containerContext - * @return a new IDTExternalContext for the containerContext refered - * to by containerContext. - */ - public abstract IDTExternalContext create(IAdaptable containerContext); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractExternalContextFactoryLocator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractExternalContextFactoryLocator.java deleted file mode 100644 index 77ae0861d..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/AbstractExternalContextFactoryLocator.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2007 Oracle Corporation 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jst.jsf.designtime.context; - -/** - * Parent of all implementers of IExternalContextFactoryLocator - * @author cbateman - * - */ -public abstract class AbstractExternalContextFactoryLocator implements - IExternalContextFactoryLocator -{ - /** - * @return the current external context factory - */ - public abstract AbstractDTExternalContextFactory getFactory(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTFacesContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTFacesContext.java deleted file mode 100644 index ccecca520..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTFacesContext.java +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jst.jsf.common.internal.resource.IResourceLifecycleListener; -import org.eclipse.jst.jsf.common.internal.resource.LifecycleListener; -import org.eclipse.jst.jsf.common.internal.resource.ResourceLifecycleEvent; -import org.eclipse.jst.jsf.common.internal.resource.ResourceLifecycleEvent.EventType; -import org.eclipse.jst.jsf.designtime.DesignTimeApplicationManager; -import org.eclipse.jst.jsf.designtime.internal.view.IDTViewHandler; -import org.eclipse.jst.jsf.designtime.internal.view.IViewRootHandle; - -/** - * Represents a design-time version of the JSF FacesContext for a particular web - * application. - * - * Client may not sub-class. - * - * @author cbateman - * - */ -public final class DTFacesContext -{ - private final IExternalContextFactoryLocator _locator; - private final IAdaptable _contextObject; - private final ViewRootHolder _viewRootHolder; - private LifecycleListener _lifecycleListener; - private IResourceLifecycleListener _listener; - - /** - * @param contextObject - * @param locator - */ - public DTFacesContext(final IAdaptable contextObject, - final IExternalContextFactoryLocator locator) - { - _contextObject = contextObject; - _locator = locator; - - // init last -- NOTE: it is essential that the new Object be unique - _viewRootHolder = new ViewRootHolder(this, new Object()); - } - - /** - * @param locator - * @deprecated Use DTFacesContext(IAdaptable, - * IExternalContextFactoryLocator) - */ - @Deprecated - public DTFacesContext(final IExternalContextFactoryLocator locator) - { - _locator = locator; - _contextObject = null; - - // init last -- NOTE: it is essential that the new Object be unique - _viewRootHolder = new ViewRootHolder(this, new Object()); - } - - /** - * THIS IS NOT AN API METHOD. External clients must not call. - * - * initilaize the faces context. - * @param lifecycleListener - */ - public void initialize(final LifecycleListener lifecycleListener) - { - final IResource res = adaptContextObject(); - _lifecycleListener = lifecycleListener; - - if (res != null && _lifecycleListener != null) - { - _listener = new IResourceLifecycleListener() - { - public EventResult acceptEvent(ResourceLifecycleEvent event) - { - if (res.equals(event.getAffectedResource())) - { - if (event.getEventType() == EventType.RESOURCE_INACCESSIBLE) - { - _lifecycleListener.removeResource(res); - } - } - return EventResult.getDefaultEventResult(); - } - }; - - _lifecycleListener.addResource(res); - _lifecycleListener.addListener(_listener); - } - } - - /** - * @param contextObject -- - * the object corresponding to the external context. Usually an - * IFile point to a file containing the external context. It must - * be adaptable to an IFile. - * - * @return the designtime external context or null if one is not defined for - * this contextObject - */ - public IDTExternalContext getDTExternalContext( - final IAdaptable contextObject) - { - IDTExternalContext externalContext = null; - - // if the context object is an IFile or can be adapted to one, create a - // new externalContext for it - if (contextObject instanceof IFile - || (contextObject != null && contextObject - .getAdapter(IFile.class) != null)) - { - - final AbstractDTExternalContextFactory factory = _locator - .getFactory(); - externalContext = factory.create(contextObject); - } - return externalContext; - } - - /** - * <p> - * Returns a new copy of the view root handle. - * </p> - * - * return null if the value of the view root - * - * @return the cached view root. May be null. - */ - public IViewRootHandle getViewRootHandle() - { - return _viewRootHolder.clone(); - } - - /** - * @deprecated - */ - @Deprecated - private String _localeString = ""; //$NON-NLS-1$ - - /** - * @return the current locale string - * @deprecated Use IDTViewHandler.calculateLocale instead - */ - @Deprecated - public String getLocaleString() - { - return _localeString; - } - - /** - * @param newLocaleString - * @deprecated Use IDTViewHandler.calculateLocale instead - */ - @Deprecated - public void setLocaleString(final String newLocaleString) - { - _localeString = newLocaleString; - } - - /** - * @return the resource correspondinng to context object or null if it - * cannot be adapted to an IResource - */ - public IResource adaptContextObject() - { - if (_contextObject instanceof IResource) - { - return (IResource) _contextObject; - } - else if (_contextObject != null - && _contextObject.getAdapter(IResource.class) != null) - { - return (IResource) _contextObject.getAdapter(IResource.class); - } - return null; - } - - IDTViewHandler getViewHandler(final IResource res) - { - IDTViewHandler viewHandler = null; - - if (res != null) - { - final DesignTimeApplicationManager manager = DesignTimeApplicationManager - .getInstance(res.getProject()); - if (manager != null) - { - viewHandler = manager.getViewHandler(); - } - } - return viewHandler; - } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTJSPExternalContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTJSPExternalContext.java deleted file mode 100644 index 8c870d1c8..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DTJSPExternalContext.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import java.io.PrintStream; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jst.j2ee.web.componentcore.util.WebArtifactEdit; -import org.eclipse.jst.jsf.common.JSFCommonPlugin; -import org.eclipse.jst.jsf.context.symbol.ISymbol; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolConstants; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolSourceProvider; -import org.eclipse.jst.jsf.context.symbol.source.ISymbolSourceProviderFactory; - - -/** - * A designtime proxy for the Faces ExternalContext - * - * Clients may sub-class. - * - * @author cbateman - * - */ -public class DTJSPExternalContext extends AbstractDTExternalContext -{ - /** - * - */ - private final IFile _jspFile; - - /** - * Construct a default external context - * - * @param jspFile - */ - protected DTJSPExternalContext(final IAdaptable jspFile) - { - if (jspFile instanceof IFile) - { - _jspFile = (IFile) jspFile; - } - else if (jspFile != null) - { - IFile file = (IFile) jspFile.getAdapter(IFile.class); - - if (file != null) - { - _jspFile = file; - } - else - { - _jspFile = null; - throw new AssertionError("jspFile must be adapable to an IFile"); //$NON-NLS-1$ - } - } - else - { - _jspFile = null; - throw new AssertionError("jspFile must be adapable to an IFile"); //$NON-NLS-1$ - } - } - - @Override - protected Map doGetMapForScope(final int scopeMask) - { - final Map map = new HashMap(); - - for (final Iterator it = JSFCommonPlugin.getSymbolSourceProviders().iterator(); it.hasNext();) - { - final ISymbolSourceProviderFactory factory = (ISymbolSourceProviderFactory) it.next(); - final ISymbolSourceProvider provider = factory.createInstance(_jspFile.getProject()); - - final ISymbol[] symbols = provider.getSymbols(_jspFile, scopeMask); - - for (int i = 0; i < symbols.length; i++) - { - map.put(symbols[i].getName(), symbols[i]); - } - } - - return map; - } - - /** - * @param stream - */ - public final void trace(PrintStream stream) - { - String[] scopeNames = {ISymbolConstants.SYMBOL_SCOPE_REQUEST_STRING, - ISymbolConstants.SYMBOL_SCOPE_SESSION_STRING, - ISymbolConstants.SYMBOL_SCOPE_APPLICATION_STRING, - ISymbolConstants.SYMBOL_SCOPE_NONE_STRING - }; - Map[] symbolMaps = {getRequestMap(), getSessionMap(), getApplicationMap(), getNoneMap()}; - - for (int i = 0; i < scopeNames.length; i++) - { - stream.println("--------------"); //$NON-NLS-1$ - stream.println(scopeNames[i]+" Scope:"); //$NON-NLS-1$ - stream.println("--------------"); //$NON-NLS-1$ - - for (final Iterator it = symbolMaps[i].values().iterator(); it.hasNext();) - { - ISymbol symbol = (ISymbol) it.next(); - System.out.println(symbol.getName()); - } - } - } - - @Override - public String getRequestContextPath() - { - WebArtifactEdit artifactEdit = null; - String path = null; - - try - { - // TODO: EARs? - artifactEdit = - WebArtifactEdit.getWebArtifactEditForRead(_jspFile.getProject()); - path = artifactEdit.getServerContextRoot(); - } - finally - { - if (artifactEdit != null) - { - artifactEdit.dispose(); - } - } - return path; - } - -// @Override -// public String getRequestPathInfo() { -// // TODO Auto-generated method stub -// return super.getRequestPathInfo(); -// } -// -// @Override -// public String getRequestServletPath() { -// // TODO Auto-generated method stub -// return super.getRequestServletPath(); -// } - -// private void getWebApp() -// { -// final IProject project = _jspFile.getProject(); -// -// final IModelProvider provider = -// ModelProviderManager.getModelProvider(project); -// Object webAppObj = provider.getModelObject(); -// -// if (webAppObj != null) -// { -// // -// } -// -// } -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DefaultDTExternalContextFactory.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DefaultDTExternalContextFactory.java deleted file mode 100644 index 1d2af78b3..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/DefaultDTExternalContextFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import org.eclipse.core.runtime.IAdaptable; - -/** - * Creates external contexts for JSPs - * - * Clients may sub-class - * - * @author cbateman - * - */ -public class DefaultDTExternalContextFactory extends - AbstractDTExternalContextFactory -{ - - /** - * @param containerContext -- must be adaptable to an IFile of content type - * JSP - * - * @return a new DT external context - */ - public IDTExternalContext create(final IAdaptable containerContext) - { - return new DTJSPExternalContext(containerContext); - } - -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IDTExternalContext.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IDTExternalContext.java deleted file mode 100644 index 2b76cb8af..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IDTExternalContext.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -import java.util.Map; - -import org.eclipse.jst.jsf.context.symbol.ISymbol; - -/** - * Interface that must be implemented by all design time external contexts - * - * Clients must not implement or sub-class. Sub-class AbstractDTExternalContext instead. - * - * @author cbateman - * - */ -public interface IDTExternalContext -{ - /** - * @param scopeMask -- the scope for which to return the symbol map - * @return a map of ISymbols representing the currently available - * scope variables. Never null, empty if no symbols - * - * Map is unmodifiable (throws exception on mutation operations) - */ - Map<String, ISymbol> getMapForScope(int scopeMask); - - /** - * @return a map of ISymbols representing the currently available - * request scope variables. Never null, empty if no symbols - * - * Map is unmodifiable (throws exception on mutation operations) - */ - Map<String, ISymbol> getRequestMap(); - - /** - * @return a map of ISymbols representing the currently available - * session scope variables. Never null, empty if no symbols - * Map is unmodifiable (throws exception on mutation operations) - */ - Map<String, ISymbol> getSessionMap(); - - /** - * @return a map of ISymbols representing the currently available - * application scope variables. Never null, empty if no symbols - * Map is unmodifiable (throws exception on mutation operations) - */ - Map<String, ISymbol> getApplicationMap(); - - /** - * @return a map of ISymbols representing the currently available - * none scope variables. Never null, empty if no symbols - * Map is unmodifiable (throws exception on mutation operations) - */ - Map<String, ISymbol> getNoneMap(); - - /** - * Servlet 2.3_SRV.4.4: The context path of the application. - * - * @return the request context path - */ - String getRequestContextPath(); - - /** - * Find all of the possible url-pattern's in the container that - * could match the underlying resource. Normally this will be single - * element list. It will only - * - * @return - */ -// List<String> getAllContainerMappings(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IExternalContextFactoryLocator.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IExternalContextFactoryLocator.java deleted file mode 100644 index 0842ed8b4..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/IExternalContextFactoryLocator.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Oracle Corporation. - * 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: - * Cameron Bateman/Oracle - initial API and implementation - * - ********************************************************************************/ - -package org.eclipse.jst.jsf.designtime.context; - -/** - * This interface is used to decouple the faces context from the - * DesignTimeApplicationManager - * - * Client must NOT implement or subclass. - * Extend AbstractExternalContextFactoryLocator instead - * - * @author cbateman - * - */ -public interface IExternalContextFactoryLocator -{ - /** - * @return the current external context factory - */ - AbstractDTExternalContextFactory getFactory(); -} diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/ViewRootHolder.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/ViewRootHolder.java deleted file mode 100644 index d33349622..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/ViewRootHolder.java +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2008 Oracle Corporation 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: - * Oracle Corporation - initial API and implementation - *******************************************************************************/ -/** - * - */ -package org.eclipse.jst.jsf.designtime.context; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jst.jsf.core.internal.JSFCorePlugin; -import org.eclipse.jst.jsf.designtime.internal.view.DTUIViewRoot; -import org.eclipse.jst.jsf.designtime.internal.view.IDTViewHandler; -import org.eclipse.jst.jsf.designtime.internal.view.IViewRootHandle; -import org.eclipse.jst.jsf.designtime.internal.view.DTUIViewRoot.StalenessListener; -import org.eclipse.jst.jsf.designtime.internal.view.IDTViewHandler.ViewHandlerException; - -/* package */ final class ViewRootHolder implements IViewRootHandle, Cloneable -{ - private final Object _recalcViewRootExclusion; - private final DTFacesContext _facesContext; - private DTUIViewRoot _viewRoot; - private final List<StalenessListener> _waitingToAdd; - private final List<StalenessListener> _waitingToRemove; - - public ViewRootHolder(final DTFacesContext facesContext, final Object recalcViewRootExclusion) - { - _facesContext = facesContext; - _recalcViewRootExclusion = recalcViewRootExclusion; - _waitingToAdd = new ArrayList<StalenessListener>(); - _waitingToRemove = new ArrayList<StalenessListener>(); - } - - private ViewRootHolder(ViewRootHolder cloneFrom) - { - _recalcViewRootExclusion = cloneFrom._recalcViewRootExclusion; - _facesContext = cloneFrom._facesContext; - _viewRoot = cloneFrom.getCachedViewRoot(); - - // create brand new copies - _waitingToAdd = new ArrayList<StalenessListener>(); - _waitingToRemove = new ArrayList<StalenessListener>(); - } - - public synchronized DTUIViewRoot getCachedViewRoot() - { - return _viewRoot; - } - - public DTUIViewRoot updateViewRoot() - { - DTUIViewRoot viewRoot = null; - final IResource contextResource = _facesContext.adaptContextObject(); - - // we create this additional exclusion so that we avoid a - // situation - // where two threads enter and start recalculating the same view - // root in parallel. Only one thread may be working on creating - // a new view root for a particular view at any given time. Note - // that due to read/write lock on the value, there is nothing - // to stop readers from simultaneous getting the old value until - // the new value is ready and has been set. - synchronized (_recalcViewRootExclusion) - { - viewRoot = getCachedViewRoot(); - - if (viewRoot == null || viewRoot.isStale()) - { - // if the view root hasn't been created, then do so - // and populate it - final IDTViewHandler viewHandler = _facesContext - .getViewHandler(contextResource); - - if (viewHandler != null) - { - final String viewId = viewHandler.getViewId( - _facesContext, contextResource); - - try - { - viewRoot = viewHandler.createView(_facesContext, - viewId); - if (viewRoot != null) - { - setCachedViewRoot(viewRoot); - } - - // do adds first, let remove trump all - for (final StalenessListener addListener : _waitingToAdd) - { - viewRoot.addListener(addListener); - } - - for (final StalenessListener removeListener : _waitingToRemove) - { - viewRoot.removeListener(removeListener); - } - } - catch (final ViewHandlerException e) - { - JSFCorePlugin.log(e, - "While creating dt viewroot for viewId: " //$NON-NLS-1$ - + viewId); - } - } - } - } - // return the copy. NEVER return _viewRoot directly since we are not - // synchronized here. - return viewRoot; - } - - private synchronized void setCachedViewRoot( - final DTUIViewRoot newViewRoot) - { - if (!Thread.holdsLock(_recalcViewRootExclusion)) - { - throw new IllegalStateException( - "Must hold _recalcViewRootExclusion to modify view root"); //$NON-NLS-1$ - } - _viewRoot = newViewRoot; - } - - @Override - protected synchronized IViewRootHandle clone() - { - return new ViewRootHolder(this); - } - - public void addListener(StalenessListener listener) - { - if (_viewRoot != null) - { - synchronized(this) - { - _viewRoot.addListener(listener); - } - } - else - { - // ensure that if we calculating a new view root, then there isn't - // an issue. - synchronized(_recalcViewRootExclusion) - { - synchronized(this) - { - _waitingToAdd.add(listener); - } - } - } - } - - public void removeListener(StalenessListener listener) - { - DTUIViewRoot viewRoot = null; - - synchronized(this) - { - viewRoot = _viewRoot; - } - - if (viewRoot != null) - { - synchronized(this) - { - viewRoot.removeListener(listener); - } - } - else - { - // ensure that if we calculating a new view root, then there isn't - // an issue. - // always acquire the recalcViewRootExclusion first - synchronized(_recalcViewRootExclusion) - { - synchronized(this) - { - _waitingToAdd.add(listener); - } - } - } - } -}
\ No newline at end of file diff --git a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/package-info.java b/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/package-info.java deleted file mode 100644 index 82480ed5f..000000000 --- a/jsf/plugins/org.eclipse.jst.jsf.core/src/org/eclipse/jst/jsf/designtime/context/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 Oracle Corporation. - * 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: - * Oracle - initial API and implementation - * - ********************************************************************************/ - -/** - * JSF Design Time Context Simulation Classes. - */ -package org.eclipse.jst.jsf.designtime.context; |