Author: snjeza
Date: 2008-11-26 17:29:50 -0500 (Wed, 26 Nov 2008)
New Revision: 12089
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/PortletRuntimeLibrariesContainerInitializer.java
Removed:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet10LibrariesContainerInitializer.java
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF
trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/Messages.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/BasePortletClasspathContainer.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/PortletRuntimeComponentProvider.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDataModelProvider.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetPrimaryRuntimeChangedListener.java
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/messages.properties
Log:
JBIDE-2792 Add runtime support for portal
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF 2008-11-26
20:22:41 UTC (rev 12088)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/META-INF/MANIFEST.MF 2008-11-26
22:29:50 UTC (rev 12089)
@@ -7,6 +7,7 @@
Bundle-Vendor: %BundleVendor
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.wst.common.project.facet.core,
+ org.eclipse.jst.common.project.facet.core,
org.eclipse.core.resources,
org.eclipse.wst.common.frameworks,
org.eclipse.jst.j2ee,
@@ -20,7 +21,8 @@
org.eclipse.ui.ide,
org.eclipse.jem,
org.eclipse.jst.jsf.facesconfig,
- org.eclipse.wst.server.core
+ org.eclipse.wst.server.core,
+ org.eclipse.jem.util
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.portlet.core,
org.jboss.tools.portlet.core.internal,
Modified: trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml
===================================================================
--- trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-11-26 20:22:41 UTC
(rev 12088)
+++ trunk/portlet/plugins/org.jboss.tools.portlet.core/plugin.xml 2008-11-26 22:29:50 UTC
(rev 12089)
@@ -83,14 +83,15 @@
</extension>
<extension
point="org.eclipse.jdt.core.classpathContainerInitializer">
- <classpathContainerInitializer
class="org.jboss.tools.portlet.core.internal.Portlet10LibrariesContainerInitializer"
-
id="org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v10"/>
- </extension>
- <extension
point="org.eclipse.jdt.core.classpathContainerInitializer">
<classpathContainerInitializer
class="org.jboss.tools.portlet.core.internal.Portlet20LibrariesContainerInitializer"
id="org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v20"/>
</extension>
+ <extension
point="org.eclipse.jdt.core.classpathContainerInitializer">
+ <classpathContainerInitializer
class="org.jboss.tools.portlet.core.internal.PortletRuntimeLibrariesContainerInitializer"
+
id="org.jboss.tools.portlet.core.internal.portletlibrarycontainer.runtime"/>
+ </extension>
+
<extension point="org.eclipse.wst.common.project.facet.core.facets">
<project-facet id="jboss.jsfportlet">
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/IPortletConstants.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -32,11 +32,11 @@
static final String PORTLET_FACET_VERSION_20 = "2.0"; //$NON-NLS-1$
static final String JSFPORTLET_FACET_VERSION_10 = "1.0"; //$NON-NLS-1$
-
- static final String PORTLET_CONTAINER_10_ID =
"org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v10";
//$NON-NLS-1$
static final String PORTLET_CONTAINER_20_ID =
"org.jboss.tools.portlet.core.internal.portletlibrarycontainer.v20";
//$NON-NLS-1$
+ static final String PORTLET_RUNTIME_CONTAINER_ID=
"org.jboss.tools.portlet.core.internal.portletlibrarycontainer.runtime";
//$NON-NLS-1$
+
static final String JSFPORTLET_CONTAINER_10_ID =
"org.jboss.tools.portlet.core.internal.jsfportletlibrarycontainer.v10";
//$NON-NLS-1$
static final String PORTLET_INSTANCES_FILE = "WEB-INF/portlet-instances.xml";
//$NON-NLS-1$
@@ -54,5 +54,32 @@
static final String WEB_INF_LIB = "WEB-INF/lib"; //$NON-NLS-1$
static final String JBOSS_PORTLET_FILE = "WEB-INF/jboss-portlet.xml";
//$NON-NLS-1$
+
+ static final String DEPLOY_PORTLET_JARS = "DEPLOY_PORTLET_JARS";
//$NON-NLS-1$
+
+ static final String ENABLE_IMPLEMENTATION_LIBRARY =
"ENABLE_IMPLEMENTATION_LIBRARY"; //$NON-NLS-1$
+ static final String PORTLET_SECTION = "portletSection"; //$NON-NLS-1$
+
+ static final String USER_LIBRARY = Messages.IPortletConstants_User_library;
+
+ static final String LIBRARY_PROVIDED_BY_JBOSS_TOOLS =
Messages.IPortletConstants_Library_provided_by_JBoss_Tools;
+
+ static final String LIBRARIES_PROVIDED_BY_SERVER_RUNTIME =
Messages.IPortletConstants_Libraries_provided_by_server_runtime;
+
+ static final String IMPLEMENTATION_LIBRARY = "implementationLibrary";
//$NON-NLS-1$
+
+ static final String USER_LIBRARY_NAME = "userLibraryName"; //$NON-NLS-1$
+
+ static final String SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_SAR =
"server/default/deploy/jboss-portal.sar"; //$NON-NLS-1$
+
+ static final String SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL =
"server/default/deploy/simple-portal"; //$NON-NLS-1$
+
+ static final String TOMCAT_LIB = "lib"; //$NON-NLS-1$
+
+ static final String JAR = ".jar"; //$NON-NLS-1$
+
+ static final String PORTLET_API = "portlet-api"; //$NON-NLS-1$
+
+
}
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/Messages.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/Messages.java 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/Messages.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -5,6 +5,9 @@
public class Messages extends NLS {
private static final String BUNDLE_NAME =
"org.jboss.tools.portlet.core.messages"; //$NON-NLS-1$
public static String BasePortletClasspathContainer_Error_loading_classpath_container;
+ public static String IPortletConstants_Libraries_provided_by_server_runtime;
+ public static String IPortletConstants_Library_provided_by_JBoss_Tools;
+ public static String IPortletConstants_User_library;
public static String
JSFPortlet10LibrariesContainerInitializer_Error_loading_classpath_container;
public static String
JSFPortlet10LibrariesContainerInitializer_JBoss_JSF_Portlet_Libraries_v1_0;
public static String
JSFPortlet10LibrariesContainerInitializer_JBossJSF_Portlet_Classpath_Container_Initializer_v1_0;
@@ -14,15 +17,16 @@
public static String JSFPortletFacetInstallDelegate_Error_loading_classpath_container;
public static String JSFPortletFacetInstallDelegate_Missing_configuration;
public static String JSFPortletFacetInstallDelegate_The_web_xml_file_is_not_updateable;
- public static String Portlet10LibrariesContainerInitializer_1;
- public static String
Portlet10LibrariesContainerInitializer_JBoss_Portlet_Classpath_Container_Initializer_v1_0;
public static String
Portlet20LibrariesContainerInitializer_JBoss_Portlet_Classpath_Container_Initializer;
+ public static String
PortletLibrariesContainerInitializer_JBoss_Portlet_Classpath_Container_Initializer;
public static String Portlet20LibrariesContainerInitializer_JBoss_Portlet_Library;
+ public static String PortletLibrariesContainerInitializer_JBoss_Portlet_Library;
public static String PortletConfigurationPresetFactory10_Portlet_Project_v1_0;
public static String
PortletFacetInstallDelegate_Cannot_configure_web_module_for_JBoss_Portlet_Facet;
public static String
PortletFacetInstallDelegate_Exception_occured_while_creating_portlet_xml;
public static String PortletFacetInstallDelegate_Missing_configuration;
public static String PortletFacetInstallDelegate_The_web_xml_file_is_not_updateable;
+ public static String PortletFacetInstallDelegate_User_library_name_is_invalid;
public static String PortletPostInstallListener_Cannot_find_Portletbridge_Runtime;
public static String PortletPostInstallListener_Cannot_find_the_examples_directory;
public static String
PortletPostInstallListener_Cannot_find_the_RichFacesPortlet_war_file;
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/BasePortletClasspathContainer.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/BasePortletClasspathContainer.java 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/BasePortletClasspathContainer.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -1,96 +1,24 @@
package org.jboss.tools.portlet.core.internal;
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IAccessRule;
-import org.eclipse.jdt.core.IClasspathAttribute;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.IJavaProject;
import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainer;
-import org.jboss.ide.eclipse.as.classpath.core.xpl.ClasspathDecorations;
-import org.jboss.tools.portlet.core.Messages;
-import org.jboss.tools.portlet.core.PortletCoreActivator;
-public abstract class BasePortletClasspathContainer extends AbstractClasspathContainer {
- private static final String PORTLET_FOLDER = "portlet"; //$NON-NLS-1$
- public final static String SUFFIX = PORTLET_FOLDER;//$NON-NLS-1$
- public final static String PREFIX = "org.jboss.tools.portlet.core";
//$NON-NLS-1$
- private static final String RESOURCES_FOLDER = "resources"; //$NON-NLS-1$
+public abstract class BasePortletClasspathContainer extends
+ AbstractClasspathContainer {
- public BasePortletClasspathContainer(IPath path, String description,String suffix) {
- super(path, description, suffix);
- }
+ protected static final String PORTLET_FOLDER = "portlet"; //$NON-NLS-1$
+ public final static String SUFFIX = PORTLET_FOLDER;//$NON-NLS-1$
+ public final static String PREFIX = "org.jboss.tools.portlet.core";
//$NON-NLS-1$
+ private IJavaProject project;
- @Override
- protected String getBaseDir() {
- try {
- URL installURL = FileLocator.toFileURL(PortletCoreActivator
- .getDefault().getBundle().getEntry("/")); //$NON-NLS-1$
- return installURL.getFile().toString();
- } catch (IOException e) {
- PortletCoreActivator
- .log(e, Messages.BasePortletClasspathContainer_Error_loading_classpath_container);
- }
- return null;
- }
+ public BasePortletClasspathContainer(IJavaProject project, IPath path,
+ String description, String suffix) {
+ super(path, description, suffix);
+ this.project = project;
+ }
- @Override
- protected IClasspathEntry[] computeEntries() {
- ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
-
- String baseDir = getBaseDir();
- if (baseDir == null)
- return new IClasspathEntry[0];
-
- String version = getPortletVersion();
- File libDir = new File(baseDir
- + "/" + RESOURCES_FOLDER + "/" + PORTLET_FOLDER + "/"
+ version);//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- File[] jars = libDir.listFiles(new FileFilter() {
- public boolean accept(File file) {
- return (file.toString().endsWith(".jar"));//$NON-NLS-1$
- }
- });
-
- if (jars != null) {
- for (int i = 0; i < jars.length; i++) {
- File jarFile = jars[i];
-
- IPath entryPath = new Path(jarFile.toString());
-
- IPath sourceAttachementPath = null;
- IPath sourceAttachementRootPath = null;
-
- final ClasspathDecorations dec = decorations
- .getDecorations(getDecorationManagerKey(getPath()
- .toString()), entryPath.toString());
-
- IClasspathAttribute[] attrs = {};
- if (dec != null) {
- sourceAttachementPath = dec.getSourceAttachmentPath();
- sourceAttachementRootPath = dec
- .getSourceAttachmentRootPath();
- attrs = dec.getExtraAttributes();
- }
-
- IAccessRule[] access = {};
- IClasspathEntry entry = JavaCore.newLibraryEntry(entryPath,
- sourceAttachementPath, sourceAttachementRootPath,
- access, attrs, false);
- entries.add(entry);
- }
- }
-
- return entries.toArray(new IClasspathEntry[entries.size()]);
- }
-
- protected abstract String getPortletVersion();
-
+ public IJavaProject getProject() {
+ return project;
+ }
}
Deleted:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet10LibrariesContainerInitializer.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet10LibrariesContainerInitializer.java 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet10LibrariesContainerInitializer.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -1,53 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008 JBoss, a division of Red Hat 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:
- * JBoss, a division of Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.portlet.core.internal;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IJavaProject;
-import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainer;
-import
org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainerInitializer;
-import org.jboss.tools.portlet.core.IPortletConstants;
-import org.jboss.tools.portlet.core.Messages;
-
-/**
- * @author snjeza
- *
- */
-public class Portlet10LibrariesContainerInitializer extends
- AbstractClasspathContainerInitializer {
-
- public String getDescription(IPath containerPath, IJavaProject project) {
- return
Messages.Portlet10LibrariesContainerInitializer_JBoss_Portlet_Classpath_Container_Initializer_v1_0;
- }
-
- @Override
- protected AbstractClasspathContainer createClasspathContainer(IPath path) {
- return new Portlet10ClasspathContainer(path);
- }
-
- @Override
- protected String getClasspathContainerID() {
- return IPortletConstants.PORTLET_CONTAINER_10_ID;
- }
-
- private class Portlet10ClasspathContainer extends BasePortletClasspathContainer {
-
- public Portlet10ClasspathContainer(IPath path) {
- super(path, Messages.Portlet10LibrariesContainerInitializer_1, SUFFIX);
- }
-
- @Override
- protected String getPortletVersion() {
- return IPortletConstants.PORTLET_FACET_VERSION_10;
- }
-
- }
-}
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/Portlet20LibrariesContainerInitializer.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -10,12 +10,27 @@
************************************************************************************/
package org.jboss.tools.portlet.core.internal;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainer;
import
org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainerInitializer;
+import org.jboss.ide.eclipse.as.classpath.core.xpl.ClasspathDecorations;
import org.jboss.tools.portlet.core.IPortletConstants;
import org.jboss.tools.portlet.core.Messages;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
/**
* @author snjeza
@@ -24,13 +39,22 @@
public class Portlet20LibrariesContainerInitializer extends
AbstractClasspathContainerInitializer {
+ private IJavaProject project;
+
+ @Override
+ public void initialize(IPath containerPath, IJavaProject project)
+ throws CoreException {
+ this.project = project;
+ super.initialize(containerPath, project);
+ }
+
public String getDescription(IPath containerPath, IJavaProject project) {
return
Messages.Portlet20LibrariesContainerInitializer_JBoss_Portlet_Classpath_Container_Initializer;
}
@Override
protected AbstractClasspathContainer createClasspathContainer(IPath path) {
- return new Portlet10ClasspathContainer(path);
+ return new Portlet20ClasspathContainer(path, project);
}
@Override
@@ -38,16 +62,78 @@
return IPortletConstants.PORTLET_CONTAINER_20_ID;
}
- private class Portlet10ClasspathContainer extends BasePortletClasspathContainer {
+ private class Portlet20ClasspathContainer extends BasePortletClasspathContainer {
- public Portlet10ClasspathContainer(IPath path) {
- super(path, Messages.Portlet20LibrariesContainerInitializer_JBoss_Portlet_Library,
SUFFIX);
+ private static final String RESOURCES_FOLDER = "resources"; //$NON-NLS-1$
+
+ public Portlet20ClasspathContainer(IPath path, IJavaProject project) {
+ super(project, path,
Messages.Portlet20LibrariesContainerInitializer_JBoss_Portlet_Library, SUFFIX);
}
@Override
- protected String getPortletVersion() {
- return IPortletConstants.PORTLET_FACET_VERSION_20;
+ protected IClasspathEntry[] computeEntries() {
+ ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
+
+ String baseDir = getBaseDir();
+ if (baseDir == null)
+ return new IClasspathEntry[0];
+
+ String version = IPortletConstants.PORTLET_FACET_VERSION_20;
+ File libDir = new File(baseDir
+ + "/" + RESOURCES_FOLDER + "/" + PORTLET_FOLDER + "/"
+ version);//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ File[] jars = libDir.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ return (file.toString().endsWith(".jar"));//$NON-NLS-1$
+ }
+ });
+
+ if (jars != null) {
+ for (int i = 0; i < jars.length; i++) {
+ File jarFile = jars[i];
+
+ IPath entryPath = new Path(jarFile.toString());
+
+ IPath sourceAttachementPath = null;
+ IPath sourceAttachementRootPath = null;
+
+ final ClasspathDecorations dec = decorations
+ .getDecorations(getDecorationManagerKey(getPath()
+ .toString()), entryPath.toString());
+
+ IClasspathAttribute[] attrs = {};
+ if (dec != null) {
+ sourceAttachementPath = dec.getSourceAttachmentPath();
+ sourceAttachementRootPath = dec
+ .getSourceAttachmentRootPath();
+ attrs = dec.getExtraAttributes();
+ }
+
+ IAccessRule[] access = {};
+ IClasspathEntry entry = JavaCore.newLibraryEntry(entryPath,
+ sourceAttachementPath, sourceAttachementRootPath,
+ access, attrs, false);
+ entries.add(entry);
+ }
+ }
+
+ return entries.toArray(new IClasspathEntry[entries.size()]);
}
+ @Override
+ protected String getBaseDir() {
+ try {
+ URL installURL = FileLocator.toFileURL(PortletCoreActivator
+ .getDefault().getBundle().getEntry("/")); //$NON-NLS-1$
+ return installURL.getFile().toString();
+ } catch (IOException e) {
+ PortletCoreActivator
+ .log(
+ e,
+ Messages.BasePortletClasspathContainer_Error_loading_classpath_container);
+ }
+ return null;
+ }
+
}
}
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/PortletRuntimeComponentProvider.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/PortletRuntimeComponentProvider.java 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/PortletRuntimeComponentProvider.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -12,22 +12,13 @@
import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
import org.eclipse.wst.server.core.IRuntime;
import
org.eclipse.wst.server.core.internal.facets.RuntimeFacetComponentProviderDelegate;
+import org.jboss.tools.portlet.core.IPortletConstants;
import org.jboss.tools.portlet.core.Messages;
import org.jboss.tools.portlet.core.PortletCoreActivator;
public class PortletRuntimeComponentProvider extends
RuntimeFacetComponentProviderDelegate {
- private static final String SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_SAR =
"server/default/deploy/jboss-portal.sar"; //$NON-NLS-1$
-
- private static final String SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL =
"server/default/deploy/simple-portal"; //$NON-NLS-1$
-
- private static final String LIB = "lib"; //$NON-NLS-1$
-
- private static final String JAR = ".jar"; //$NON-NLS-1$
-
- private static final String PORTLET_API = "portlet-api"; //$NON-NLS-1$
-
private static final IRuntimeComponentType PORTAL_TYPE = RuntimeManager
.getRuntimeComponentType("org.jboss.tools.portlet.core.runtime.component");
//$NON-NLS-1$
@@ -52,20 +43,20 @@
return true;
}
// JBoss Portal server
- if (exists(location, SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_SAR)) {
+ if (exists(location, IPortletConstants.SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_SAR)) {
return true;
}
// JBoss portletcontainer
- if (exists(location,SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL)) {
+ if (exists(location,IPortletConstants.SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL)) {
return true;
}
// Tomcat portletcontainer
- File tomcatLib = new File(location,LIB);
+ File tomcatLib = new File(location,IPortletConstants.TOMCAT_LIB);
if (tomcatLib.exists() && tomcatLib.isDirectory()) {
String[] files = tomcatLib.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
- if (name.startsWith(PORTLET_API) && name.endsWith(JAR)) {
+ if (name.startsWith(IPortletConstants.PORTLET_API) &&
name.endsWith(IPortletConstants.JAR)) {
return true;
}
return false;
Added:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/PortletRuntimeLibrariesContainerInitializer.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/PortletRuntimeLibrariesContainerInitializer.java
(rev 0)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/PortletRuntimeLibrariesContainerInitializer.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -0,0 +1,181 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat 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:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.portlet.core.internal;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.wst.server.core.IRuntime;
+import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainer;
+import
org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainerInitializer;
+import org.jboss.ide.eclipse.as.classpath.core.xpl.ClasspathDecorations;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.Messages;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+
+/**
+ * @author snjeza
+ *
+ */
+public class PortletRuntimeLibrariesContainerInitializer extends
+ AbstractClasspathContainerInitializer {
+
+ private IJavaProject project;
+
+ @Override
+ public void initialize(IPath containerPath, IJavaProject project)
+ throws CoreException {
+ this.project = project;
+ super.initialize(containerPath, project);
+ }
+
+ public String getDescription(IPath containerPath, IJavaProject project) {
+ return
Messages.PortletLibrariesContainerInitializer_JBoss_Portlet_Classpath_Container_Initializer;
+ }
+
+ @Override
+ protected AbstractClasspathContainer createClasspathContainer(IPath path) {
+ return new PortletRuntimeClasspathContainer(path, project);
+ }
+
+ @Override
+ protected String getClasspathContainerID() {
+ return IPortletConstants.PORTLET_RUNTIME_CONTAINER_ID;
+ }
+
+ public class PortletRuntimeClasspathContainer extends
+ BasePortletClasspathContainer {
+
+ public PortletRuntimeClasspathContainer(IPath path, IJavaProject project) {
+ super(
+ project,
+ path,
+ Messages.PortletLibrariesContainerInitializer_JBoss_Portlet_Library,
+ SUFFIX);
+ }
+
+ @Override
+ protected IClasspathEntry[] computeEntries() {
+ ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
+
+ IJavaProject javaProject = getProject();
+
+ if (javaProject != null) {
+ IProject project = javaProject.getProject();
+ if (project != null) {
+ try {
+ IRuntime runtime = J2EEProjectUtilities
+ .getServerRuntime(project);
+ if (runtime != null) {
+ File location = runtime.getLocation().toFile();
+ File libDir = getLibDirectory(location);
+ if (libDir != null) {
+ File[] jars = libDir
+ .listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ String name = file.getName();
+ return (name.startsWith(IPortletConstants.PORTLET_API) && name
+ .endsWith(IPortletConstants.JAR));
+ }
+ });
+
+ if (jars != null) {
+ for (int i = 0; i < jars.length; i++) {
+ File jarFile = jars[i];
+
+ IPath entryPath = new Path(jarFile
+ .toString());
+
+ IPath sourceAttachementPath = null;
+ IPath sourceAttachementRootPath = null;
+
+ final ClasspathDecorations dec = decorations
+ .getDecorations(
+ getDecorationManagerKey(getPath()
+ .toString()),
+ entryPath.toString());
+
+ IClasspathAttribute[] attrs = {};
+ if (dec != null) {
+ sourceAttachementPath = dec
+ .getSourceAttachmentPath();
+ sourceAttachementRootPath = dec
+ .getSourceAttachmentRootPath();
+ attrs = dec.getExtraAttributes();
+ }
+
+ IAccessRule[] access = {};
+ IClasspathEntry entry = JavaCore
+ .newLibraryEntry(
+ entryPath,
+ sourceAttachementPath,
+ sourceAttachementRootPath,
+ access, attrs, false);
+ entries.add(entry);
+ }
+ }
+ }
+ }
+ } catch (CoreException e) {
+ PortletCoreActivator.log(e);
+ }
+ }
+ }
+ return entries.toArray(new IClasspathEntry[entries.size()]);
+ }
+
+ private File getLibDirectory(File location) {
+ File libDirectory = getDirectory(location,
+ IPortletConstants.SERVER_DEFAULT_DEPLOY_JBOSS_PORTAL_SAR);
+ if (libDirectory != null) {
+ libDirectory = new File(libDirectory, "lib"); //$NON-NLS-1$
+ } else {
+ libDirectory = getDirectory(location,
+ IPortletConstants.SERVER_DEFAULT_DEPLOY_SIMPLE_PORTAL);
+ if (libDirectory != null) {
+ libDirectory = new File(libDirectory, "lib"); //$NON-NLS-1$
+ } else {
+ // Tomcat adds portlet-api.jat automatically
+ /*File tomcatLib = new File(location,
+ IPortletConstants.TOMCAT_LIB);
+ if (tomcatLib != null && tomcatLib.isDirectory()) {
+ libDirectory = tomcatLib;
+ }*/
+ }
+ }
+ return libDirectory;
+ }
+
+ private File getDirectory(File location, String portalDir) {
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ portalDir = portalDir.replace("/", "\\"); //$NON-NLS-1$
//$NON-NLS-2$
+ }
+ File file = new File(location, portalDir);
+ if (file.exists() && file.isDirectory()) {
+ return file;
+ }
+ return null;
+ }
+ }
+}
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDataModelProvider.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDataModelProvider.java 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDataModelProvider.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -10,8 +10,11 @@
************************************************************************************/
package org.jboss.tools.portlet.core.internal.project.facet;
+import java.util.Set;
+
import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.Messages;
/**
* @author snjeza
@@ -25,7 +28,30 @@
if(propertyName.equals(FACET_ID)){
return IPortletConstants.PORTLET_FACET_ID;
}
+ if (propertyName.equals(IPortletConstants.DEPLOY_PORTLET_JARS)) {
+ return Boolean.FALSE;
+ }
+ if (propertyName.equals(IPortletConstants.ENABLE_IMPLEMENTATION_LIBRARY)) {
+ return Boolean.TRUE;
+ }
+ if (propertyName.equals(IPortletConstants.USER_LIBRARY_NAME)) {
+ return ""; //$NON-NLS-1$
+ }
+ if (propertyName.equals(IPortletConstants.IMPLEMENTATION_LIBRARY)) {
+ return IPortletConstants.LIBRARY_PROVIDED_BY_JBOSS_TOOLS;
+ }
return super.getDefaultProperty(propertyName);
}
+
+ @Override
+ public Set<String> getPropertyNames() {
+ Set<String> propertyNames = super.getPropertyNames();
+ propertyNames.add(IPortletConstants.DEPLOY_PORTLET_JARS);
+ propertyNames.add(IPortletConstants.ENABLE_IMPLEMENTATION_LIBRARY);
+ propertyNames.add(IPortletConstants.USER_LIBRARY_NAME);
+ propertyNames.add(IPortletConstants.IMPLEMENTATION_LIBRARY);
+
+ return propertyNames;
+ }
}
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetInstallDelegate.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -20,6 +20,7 @@
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jst.j2ee.model.IModelProvider;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IDelegate;
@@ -76,22 +77,11 @@
}
IJavaProject javaProject = JavaCore.create(project);
+ boolean enableImplementationLibrary =
config.getBooleanProperty(IPortletConstants.ENABLE_IMPLEMENTATION_LIBRARY);
+ if (enableImplementationLibrary) {
+ setClasspath(monitor, javaProject, config);
+ }
- IPath containerPath = null;
- //if (IPortletConstants.PORTLET_FACET_VERSION_10.equals(fv.getVersionString())) {
- containerPath = new Path(IPortletConstants.PORTLET_CONTAINER_10_ID);
- //} else {
- containerPath = new Path(IPortletConstants.PORTLET_CONTAINER_20_ID);
- //}
-
- IClasspathEntry entry = JavaCore.newContainerEntry(containerPath, true);
- IClasspathEntry[] entries = javaProject.getRawClasspath();
- IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
- System.arraycopy( entries, 0, newEntries, 0, entries.length );
- newEntries[entries.length] = entry;
- javaProject.setRawClasspath(newEntries, monitor);
-
-
createPortletXml(project, fv, config, monitor);
if (monitor != null) {
@@ -105,6 +95,49 @@
}
}
+ private void setClasspath(final IProgressMonitor monitor,
+ IJavaProject javaProject, IDataModel config) throws CoreException {
+ boolean deployPortletJars =
config.getBooleanProperty(IPortletConstants.DEPLOY_PORTLET_JARS);
+ if (deployPortletJars) {
+ copyLibraries(monitor,javaProject,config);
+ } else {
+ String implementationLibrary =
config.getStringProperty(IPortletConstants.IMPLEMENTATION_LIBRARY);
+ if (IPortletConstants.LIBRARY_PROVIDED_BY_JBOSS_TOOLS.equals(implementationLibrary))
{
+ IPath containerPath = new Path(IPortletConstants.PORTLET_CONTAINER_20_ID);
+ setContainerPath(monitor, javaProject, containerPath);
+ } else if
(IPortletConstants.LIBRARIES_PROVIDED_BY_SERVER_RUNTIME.equals(implementationLibrary)) {
+ IPath containerPath = new Path(IPortletConstants.PORTLET_RUNTIME_CONTAINER_ID);
+ setContainerPath(monitor, javaProject, containerPath);
+ } else {
+ String libraryName = config.getStringProperty(IPortletConstants.USER_LIBRARY_NAME);
+ if (libraryName != null && libraryName.trim().length() > 0) {
+ IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID + "/" +
libraryName); //$NON-NLS-1$
+ setContainerPath(monitor, javaProject, containerPath);
+ } else {
+ PortletCoreActivator.log(null,
Messages.PortletFacetInstallDelegate_User_library_name_is_invalid);
+ }
+ // user library
+ //JavaCore.getCla
+ }
+
+ }
+ }
+
+ private void copyLibraries(IProgressMonitor monitor,
+ IJavaProject javaProject, IDataModel config) {
+ // TODO Auto-generated method stub
+
+ }
+
+ private void setContainerPath(IProgressMonitor monitor, IJavaProject javaProject,IPath
containerPath) throws CoreException {
+ IClasspathEntry entry = JavaCore.newContainerEntry(containerPath, true);
+ IClasspathEntry[] entries = javaProject.getRawClasspath();
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
+ System.arraycopy( entries, 0, newEntries, 0, entries.length );
+ newEntries[entries.length] = entry;
+ javaProject.setRawClasspath(newEntries, monitor);
+ }
+
private void createPortletXml(final IProject project,
final IProjectFacetVersion fv, IDataModel config,
final IProgressMonitor monitor) {
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetPrimaryRuntimeChangedListener.java
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetPrimaryRuntimeChangedListener.java 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/internal/project/facet/PortletFacetPrimaryRuntimeChangedListener.java 2008-11-26
22:29:50 UTC (rev 12089)
@@ -1,14 +1,44 @@
package org.jboss.tools.portlet.core.internal.project.facet;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
+import org.jboss.tools.portlet.core.IPortletConstants;
+import org.jboss.tools.portlet.core.PortletCoreActivator;
+import
org.jboss.tools.portlet.core.internal.PortletRuntimeLibrariesContainerInitializer;
public class PortletFacetPrimaryRuntimeChangedListener implements
IFacetedProjectListener {
public void handleEvent(IFacetedProjectEvent event) {
- // TODO Auto-generated method stub
-
+ final IFacetedProject fproj = event.getProject();
+ final IProjectFacet PORTLET_FACET = ProjectFacetsManager
+ .getProjectFacet(IPortletConstants.PORTLET_FACET_ID);
+ if (fproj.hasProjectFacet(PORTLET_FACET)) {
+ //final IProjectFacetVersion fv = fproj
+ // .getInstalledVersion(PORTLET_FACET);
+ try {
+ IPath containerPath = new Path(IPortletConstants.PORTLET_RUNTIME_CONTAINER_ID);
+ IProject project = fproj.getProject();
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathContainer containerEntry = JavaCore.getClasspathContainer(containerPath,
javaProject);
+ ClasspathContainerInitializer initializer =
JavaCore.getClasspathContainerInitializer(IPortletConstants.PORTLET_RUNTIME_CONTAINER_ID);
+ initializer.requestClasspathContainerUpdate(containerPath, javaProject,
containerEntry);
+ } catch (CoreException e) {
+ PortletCoreActivator.log(e);
+ }
+ }
}
}
Modified:
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/messages.properties
===================================================================
---
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/messages.properties 2008-11-26
20:22:41 UTC (rev 12088)
+++
trunk/portlet/plugins/org.jboss.tools.portlet.core/src/org/jboss/tools/portlet/core/messages.properties 2008-11-26
22:29:50 UTC (rev 12089)
@@ -1,4 +1,7 @@
BasePortletClasspathContainer_Error_loading_classpath_container=Error loading classpath
container
+IPortletConstants_Libraries_provided_by_server_runtime=Libraries provided by server
runtime
+IPortletConstants_Library_provided_by_JBoss_Tools=Library provided by JBoss Tools
+IPortletConstants_User_library=User library
JSFPortlet10LibrariesContainerInitializer_Error_loading_classpath_container=Error loading
classpath container
JSFPortlet10LibrariesContainerInitializer_JBoss_JSF_Portlet_Libraries_v1_0=JBoss JSF
Portlet Libraries v1.0
JSFPortlet10LibrariesContainerInitializer_JBossJSF_Portlet_Classpath_Container_Initializer_v1_0=JBoss
JSF Portlet Classpath Container Initializer v1.0
@@ -8,8 +11,8 @@
JSFPortletFacetInstallDelegate_Error_loading_classpath_container=Error loading classpath
container
JSFPortletFacetInstallDelegate_Missing_configuration=Internal Error creating JBoss JSF
Portlet Facet. Missing configuration.
JSFPortletFacetInstallDelegate_The_web_xml_file_is_not_updateable=The web.xml file is not
updateable
-Portlet10LibrariesContainerInitializer_1=JBoss Portlet Libraries v1.0
-Portlet10LibrariesContainerInitializer_JBoss_Portlet_Classpath_Container_Initializer_v1_0=JBoss
Portlet Classpath Container Initializer v1.0
+PortletLibrariesContainerInitializer_JBoss_Portlet_Library=JBoss Portlet Libraries
+PortletLibrariesContainerInitializer_JBoss_Portlet_Classpath_Container_Initializer=JBoss
Portlet Classpath Container Initializer
Portlet20LibrariesContainerInitializer_JBoss_Portlet_Classpath_Container_Initializer=JBoss
Portlet Classpath Container Initializer
Portlet20LibrariesContainerInitializer_JBoss_Portlet_Library=JBoss Portlet Library
PortletConfigurationPresetFactory10_Portlet_Project_v1_0=Portlet Project v1.0
@@ -17,6 +20,7 @@
PortletFacetInstallDelegate_Exception_occured_while_creating_portlet_xml=Exception
occured while creating portlet.xml
PortletFacetInstallDelegate_Missing_configuration=Internal Error creating JBoss Portlet
Facet. Missing configuration.
PortletFacetInstallDelegate_The_web_xml_file_is_not_updateable=The web.xml file is not
updateable
+PortletFacetInstallDelegate_User_library_name_is_invalid=User library name is invalid.
PortletPostInstallListener_Cannot_find_Portletbridge_Runtime=Cannot find Portletbridge
Runtime.
PortletPostInstallListener_Cannot_find_the_examples_directory=Cannot find the examples
directory.
PortletPostInstallListener_Cannot_find_the_RichFacesPortlet_war_file=Cannot find the
RichFacesPortlet.war file.