Initial Import of Pluto 1.1 seed code. git-svn-id: https://svn.apache.org/repos/asf/portals/pluto/branches/binding@54049 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/binding.iml b/binding.iml new file mode 100644 index 0000000..6a04d86 --- /dev/null +++ b/binding.iml
@@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module version="4" relativePaths="true" type="JAVA_MODULE"> + <component name="ModuleRootManager" /> + <component name="NewModuleRootManager"> + <output url="file://$MODULE_DIR$/target/classes" /> + <exclude-output /> + <exclude-exploded /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" /> + <excludeFolder url="file://$MODULE_DIR$/target" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="commons-digester-1.5" level="application" /> + <orderEntryProperties /> + </component> +</module> +
diff --git a/project.properties b/project.properties new file mode 100644 index 0000000..07895e2 --- /dev/null +++ b/project.properties
@@ -0,0 +1,3 @@ +maven.checkstyle.properties=${basedir}/../checkstyle.xml +maven.checkstyle.headerfile=${basedir}/../LICENSE.TXT +maven.license.licenseFile=${basedir}/../LICENSE.TXT
diff --git a/project.xml b/project.xml new file mode 100644 index 0000000..80da92c --- /dev/null +++ b/project.xml
@@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright 2004 The Apache Software Foundation. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied. + +See the License for the specific language governing permissions and +limitations under the License. +--> +<project> + <extend>${basedir}/../project.xml</extend> + <name>Portlet OM and Bindings </name> + <id>pluto-binding</id> + + <organization> + <logo>/../../images/apache-portals.gif</logo> + </organization> + + <logo>/../../images/pluto.png</logo> + + <shortDescription>A PortletSpecification OM Binding.</shortDescription> + + <description> + Parsing and Binding tools for the portlet specification. + </description> + + <dependencies> + <dependency> + <id>commons-digester</id> + <version>1.6</version> + </dependency> + </dependencies> + + <build> + <nagEmailAddress>pluto-dev@jakarta.apache.org</nagEmailAddress> + + <sourceDirectory>src/java</sourceDirectory> + <aspectSourceDirectory/> + + <unitTestSourceDirectory>src/test</unitTestSourceDirectory> + + <unitTest> + <includes> + <include>**/*Test.java</include> + </includes> + </unitTest> + + <integrationUnitTestSourceDirectory>src/rttest</integrationUnitTestSourceDirectory> + + <integrationUnitTest> + <includes> + <include>**/*Test.java</include> + </includes> + </integrationUnitTest> + + + <resources> + <resource> + <directory>src/conf</directory> + <includes> + <include>**/*.properties</include> + <include>**/*.xml</include> + </includes> + </resource> + </resources> + + <jars/> + + </build> + +</project>
diff --git a/src/java/org/apache/pluto/binding/InitParameterDD.java b/src/java/org/apache/pluto/binding/InitParameterDD.java new file mode 100644 index 0000000..0354a5c --- /dev/null +++ b/src/java/org/apache/pluto/binding/InitParameterDD.java
@@ -0,0 +1,35 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Implemented by binding provider in order to allow the retrieval of + * init-parameter bindings. + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Feb 23, 2004 at 10:12:54 PM + */ +public interface InitParameterDD { + + /** Standard Getter. */ + String getParameterName(); + + /** Standard Getter. */ + String getParameterValue(); + + /** Standard Getter. */ + String getDescription(); +}
diff --git a/src/java/org/apache/pluto/binding/MutablePortletAppDD.java b/src/java/org/apache/pluto/binding/MutablePortletAppDD.java new file mode 100644 index 0000000..d8c285c --- /dev/null +++ b/src/java/org/apache/pluto/binding/MutablePortletAppDD.java
@@ -0,0 +1,28 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pluto.binding; + + + +/** + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 9, 2004 at 4:36:23 PM + */ +public interface MutablePortletAppDD extends PortletAppDD { + +}
diff --git a/src/java/org/apache/pluto/binding/MutableXMLBindingFactory.java b/src/java/org/apache/pluto/binding/MutableXMLBindingFactory.java new file mode 100644 index 0000000..9e441e0 --- /dev/null +++ b/src/java/org/apache/pluto/binding/MutableXMLBindingFactory.java
@@ -0,0 +1,33 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pluto.binding; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 10, 2004 at 12:32:55 PM + */ +public abstract class MutableXMLBindingFactory extends XMLBindingFactory { + + public abstract void saveWebApp(WebAppDD dd, OutputStream out) + throws IOException; + +}
diff --git a/src/java/org/apache/pluto/binding/PortletAppDD.java b/src/java/org/apache/pluto/binding/PortletAppDD.java new file mode 100644 index 0000000..73e796b --- /dev/null +++ b/src/java/org/apache/pluto/binding/PortletAppDD.java
@@ -0,0 +1,35 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Implemented by the binding provider to represent the PortletApp Deployment + * Descriptor (portlet.xml) + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Feb 23, 2004 at 11:17:50 PM + */ +public interface PortletAppDD { + + public static final String PORTLET_XML = "/WEB-INF/portlet.xml"; + + /** Standard Getter. */ + PortletDD[] getPortlets(); + + /** Standard Getter. */ + InitParameterDD[] getInitParameters(); + +}
diff --git a/src/java/org/apache/pluto/binding/PortletDD.java b/src/java/org/apache/pluto/binding/PortletDD.java new file mode 100644 index 0000000..14f1437 --- /dev/null +++ b/src/java/org/apache/pluto/binding/PortletDD.java
@@ -0,0 +1,65 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Implemented by the binding provider in order to represent a PortletDD + * Binding. + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Feb 24, 2004 at 7:52:06 PM + */ +public interface PortletDD { + + /** Standard Getter. */ + String getDescription(); + + /** Standard Getter. */ + String getPortletName(); + + /** Standard Getter. */ + String getDisplayName(); + + /** Standard Getter. */ + String getPortletClass(); + + /** Standard Getter. */ + InitParameterDD[] getInitParameters(); + + /** Standard Getter. */ + int getExpirationCache(); + + /** Standard Getter. */ + SupportedMimeTypeDD[] getSupportedMimeTypes(); + + /** Standard Getter. */ + String[] getSupportedLocales(); + + /** Standard Getter. */ + PortletInfoDD getPortletInfo(); + + /** Standard Getter. */ + PortletPreferenceDD[] getPortletPreferences(); + + /** Standard Getter. */ + String getPreferenceValidator(); + + /** Standard Getter. */ + SecurityRoleRefDD[] getSecurityRoleRefs(); + + /** Standard Getter. */ + String getResourceBundle(); +}
diff --git a/src/java/org/apache/pluto/binding/PortletInfoDD.java b/src/java/org/apache/pluto/binding/PortletInfoDD.java new file mode 100644 index 0000000..7cfce75 --- /dev/null +++ b/src/java/org/apache/pluto/binding/PortletInfoDD.java
@@ -0,0 +1,37 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Portlet Information as defined by the <code>portlet.xml</code> + * deployment description. + * + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 11, 2004 at 9:59:15 AM + */ +public interface PortletInfoDD { + + /** Standard Getter. */ + String getTitle(); + + /** Standard Getter. */ + String getShortTitle(); + + /** Standard Getter. */ + String getKeywords(); + +}
diff --git a/src/java/org/apache/pluto/binding/PortletPreferenceDD.java b/src/java/org/apache/pluto/binding/PortletPreferenceDD.java new file mode 100644 index 0000000..6783a2a --- /dev/null +++ b/src/java/org/apache/pluto/binding/PortletPreferenceDD.java
@@ -0,0 +1,37 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Portlet Preferences as defined by the <code>portlet.xml</code> + * deployment descriptor. + * + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 11, 2004 at 9:57:10 AM + */ +public interface PortletPreferenceDD { + + /** Standard Getter. */ + String getName(); + + /** Standard Getter. */ + String getValue(); + + /** Standard Getter. */ + boolean isReadOnly(); + +}
diff --git a/src/java/org/apache/pluto/binding/SecurityRoleRefDD.java b/src/java/org/apache/pluto/binding/SecurityRoleRefDD.java new file mode 100644 index 0000000..d96566d --- /dev/null +++ b/src/java/org/apache/pluto/binding/SecurityRoleRefDD.java
@@ -0,0 +1,37 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Security Role Ref as defined by the <code>portlet.xml</code> + * deployment descriptor. + * + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Feb 23, 2004 at 10:18:18 PM + */ +public interface SecurityRoleRefDD { + + /** Standard Getter. */ + String getDescription(); + + /** Standard Getter. */ + String getRoleName(); + + /** Standard Getter. */ + String getRoleLink(); + +}
diff --git a/src/java/org/apache/pluto/binding/ServletDD.java b/src/java/org/apache/pluto/binding/ServletDD.java new file mode 100644 index 0000000..ed8d9b1 --- /dev/null +++ b/src/java/org/apache/pluto/binding/ServletDD.java
@@ -0,0 +1,46 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Sevlet configuration as defined by the <code>web.xml</code> + * deployment description. + * + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Feb 23, 2004 at 10:09:20 PM + */ +public interface ServletDD { + + /** Standard Getter. */ + String getServletName(); + + /** Standard Getter. */ + String getDisplayName(); + + /** Standard Getter. */ + String getDescription(); + + /** Standard Getter. */ + String getServletClass(); + + /** Standard Getter. */ + InitParameterDD[] getInitParameters(); + + /** Standard Getter. */ + SecurityRoleRefDD getSecurityRoleRef(); + +}
diff --git a/src/java/org/apache/pluto/binding/ServletMappingDD.java b/src/java/org/apache/pluto/binding/ServletMappingDD.java new file mode 100644 index 0000000..cd6d44b --- /dev/null +++ b/src/java/org/apache/pluto/binding/ServletMappingDD.java
@@ -0,0 +1,34 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Servlet Mapping configuration as defined by the <code>web.xml</code> + * deployment descriptor. + * + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Feb 23, 2004 at 10:09:29 PM + */ +public interface ServletMappingDD { + + /** Standard Getter. */ + String getServletName(); + + /** Standard Getter. */ + String getURLPattern(); + +}
diff --git a/src/java/org/apache/pluto/binding/SupportedMimeTypeDD.java b/src/java/org/apache/pluto/binding/SupportedMimeTypeDD.java new file mode 100644 index 0000000..2483ca3 --- /dev/null +++ b/src/java/org/apache/pluto/binding/SupportedMimeTypeDD.java
@@ -0,0 +1,32 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pluto.binding; + +/** + * Supported Mime Type configuration as defined by the <code>web.xml</code> + * deployment descriptor. + * + * @author <a href="ddewolf@apache.org">David H. DeWolf</a> + * @version 1.0 + * @since Sep 20, 2004 + */ +public interface SupportedMimeTypeDD { + + String getMimeType(); + + String[] getPortletModes(); +}
diff --git a/src/java/org/apache/pluto/binding/TaglibDD.java b/src/java/org/apache/pluto/binding/TaglibDD.java new file mode 100644 index 0000000..e34d206 --- /dev/null +++ b/src/java/org/apache/pluto/binding/TaglibDD.java
@@ -0,0 +1,34 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Taglibrary definition as defined by the <code>web.xml</code> + * deployment descriptor. + * + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Feb 24, 2004 at 7:26:56 PM + */ +public interface TaglibDD { + String getTaglibUri(); + + String getTaglibLocation(); + + void setTaglibUri(String uri); + + void setTaglibLocation(String location); +}
diff --git a/src/java/org/apache/pluto/binding/WebAppDD.java b/src/java/org/apache/pluto/binding/WebAppDD.java new file mode 100644 index 0000000..fdfc7f2 --- /dev/null +++ b/src/java/org/apache/pluto/binding/WebAppDD.java
@@ -0,0 +1,34 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +/** + * Web Application configuration container as defined by the + * <code>web.xml</code> deployment descriptor. + * + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Feb 23, 2004 at 10:04:17 PM + */ +public interface WebAppDD { + + ServletDD[] getServlets(); + + ServletMappingDD[] getServletMappings(); + + TaglibDD[] getTaglibs(); + +}
diff --git a/src/java/org/apache/pluto/binding/XMLBindingFactory.java b/src/java/org/apache/pluto/binding/XMLBindingFactory.java new file mode 100644 index 0000000..da43976 --- /dev/null +++ b/src/java/org/apache/pluto/binding/XMLBindingFactory.java
@@ -0,0 +1,110 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.pluto.binding.impl.digester.DigesterXMLBindingFactory; + +/** + * <P>Factory used to read (and potentially) write deployment descriptors, + * specifically Portlet Application (<code>portlet.xml</code>) and Web + * application (<code>web.xml</code> descriptors.</P> + * + * <P>These bindingFactory functions have been abstracted from the container because + * of the frequency with which they are needed externally. Tools such as the + * pluto deployer depend on the ability to read these descriptors but rarely + * need the remainder of the container during runtime.</P> + * + * + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Feb 23, 2004 at 8:02:50 PM + */ +public abstract class XMLBindingFactory { + + /** Mode flag identifying the bindingFactory factory as read only. */ + public static final int READ_ONLY = 0; + + /** Mode flag identifying the bindingFactory factory as read/write. */ + public static final int READ_WRITE = 1; + + private static XMLBindingFactory bindingFactory; + + /** + * Create an instance of the default <code>XMLBindingFactory</code>. + */ + public static XMLBindingFactory createXMLBinding() { + return createXMLBinding(READ_ONLY); + } + + /** + * Create an instance of the <code>XMLBindingFactory</code> + * which supports the given mode. + * + * @param mode + * @return an XMLBindingFactory instance which supports the given mode. + */ + public static XMLBindingFactory createXMLBinding(int mode) { + if (bindingFactory == null) { + String clName = System.getProperty(XMLBindingFactory.class.getName()); + if (clName != null) { + try { + Class cl = Class.forName(clName); + bindingFactory = (XMLBindingFactory) cl.newInstance(); + } catch (Throwable t) { + System.out.println("Unable to instantiate XMLBindingFactory [" + + clName + "] :" + t.getMessage()); + System.out.println("Using default XMLBindingFactory"); + } + } + if (bindingFactory == null) { + bindingFactory = new DigesterXMLBindingFactory(); + } + } + return bindingFactory; + } + + /** + * Retrieve the mode this factory supports. + * @return + */ + public abstract int getMode(); + + /** + * Retrieve the Web Application deployment descriptor + * (<code>web.xml</code>) read from the given <code>InputStream</code> + * + * @param in the <code>InputStream<code> from which the descriptor should be parsed. + * @return an object representation of the descriptor. + * @throws IOException if a read error occurs. + * + */ + public abstract WebAppDD getWebAppDD(InputStream in) + throws IOException; + + /** + * Retrieve the Portlet Application deployment descriptor + * (<code>portlet.xml</code>) read from the given <code>InputStream</code> + * + * @param in + * @return + * @throws IOException + */ + public abstract PortletAppDD getPortletAppDD(InputStream in) + throws IOException; +}
diff --git a/src/java/org/apache/pluto/binding/impl/digester/DigesterInitParameterDD.java b/src/java/org/apache/pluto/binding/impl/digester/DigesterInitParameterDD.java new file mode 100644 index 0000000..9ff7ad5 --- /dev/null +++ b/src/java/org/apache/pluto/binding/impl/digester/DigesterInitParameterDD.java
@@ -0,0 +1,54 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding.impl.digester; + +import org.apache.pluto.binding.InitParameterDD; + +/** + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 11, 2004 at 9:22:27 AM + */ +public class DigesterInitParameterDD implements InitParameterDD { + + private String parameterName; + private String parameterValue; + private String description; + + public String getParameterName() { + return parameterName; + } + + public void setParameterName(String parameterName) { + this.parameterName = parameterName; + } + + public String getParameterValue() { + return parameterValue; + } + + public void setParameterValue(String parameterValue) { + this.parameterValue = parameterValue; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +}
diff --git a/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletAppDD.java b/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletAppDD.java new file mode 100644 index 0000000..de76557 --- /dev/null +++ b/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletAppDD.java
@@ -0,0 +1,55 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding.impl.digester; + +import java.util.ArrayList; + +import org.apache.pluto.binding.InitParameterDD; +import org.apache.pluto.binding.PortletAppDD; +import org.apache.pluto.binding.PortletDD; + +/** + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 10, 2004 at 5:15:34 PM + */ +public class DigesterPortletAppDD implements PortletAppDD { + + private ArrayList portlets; + private ArrayList params; + + public DigesterPortletAppDD() { + portlets = new ArrayList(); + params = new ArrayList(); + } + + public PortletDD[] getPortlets() { + return (PortletDD[]) portlets.toArray(new PortletDD[portlets.size()]); + } + + public void addPortlet(PortletDD dd) { + portlets.add(dd); + } + + public InitParameterDD[] getInitParameters() { + return (InitParameterDD[]) params.toArray( + new InitParameterDD[params.size()]); + } + + public void addInitParameter(InitParameterDD dd) { + params.add(dd); + } +}
diff --git a/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletDD.java b/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletDD.java new file mode 100644 index 0000000..1c76ce6 --- /dev/null +++ b/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletDD.java
@@ -0,0 +1,169 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pluto.binding.impl.digester; + +import java.util.ArrayList; + +import org.apache.pluto.binding.InitParameterDD; +import org.apache.pluto.binding.PortletDD; +import org.apache.pluto.binding.PortletInfoDD; +import org.apache.pluto.binding.PortletPreferenceDD; +import org.apache.pluto.binding.SecurityRoleRefDD; +import org.apache.pluto.binding.SupportedMimeTypeDD; + +/** + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 10, 2004 at 5:21:11 PM + */ +public class DigesterPortletDD implements PortletDD { + + private String description; + private String portletName; + private String displayName; + private String portletClass; + + private PortletInfoDD portletInfo; + private ArrayList portletPreferences; + + private int expirationCache; + private String preferencesValidator; + private String resourceBundle; + + private ArrayList initParameters; + private ArrayList mimeTypeSupport; + private ArrayList localeSupport; + private ArrayList securityRoleRef; + + + public DigesterPortletDD() { + this.portletPreferences = new ArrayList(); + this.initParameters = new ArrayList(); + this.mimeTypeSupport = new ArrayList(); + this.localeSupport = new ArrayList(); + this.securityRoleRef = new ArrayList(); + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getPortletName() { + return portletName; + } + + public void setPortletName(String portletName) { + this.portletName = portletName; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getPortletClass() { + return portletClass; + } + + public void setPortletClass(String portletClass) { + this.portletClass = portletClass; + } + + public InitParameterDD[] getInitParameters() { + return (InitParameterDD[]) initParameters.toArray( + new InitParameterDD[initParameters.size()]); + } + + public void addInitParameter(InitParameterDD initParameter) { + this.initParameters.add(initParameter); + } + + public int getExpirationCache() { + return expirationCache; + } + + public void setExpirationCache(int cache) { + this.expirationCache = cache; + } + + public SupportedMimeTypeDD[] getSupportedMimeTypes() { + return (SupportedMimeTypeDD[]) mimeTypeSupport + .toArray(new SupportedMimeTypeDD[mimeTypeSupport.size()]); + } + + public void addSupportedMimeType(SupportedMimeTypeDD mimeType) { + this.mimeTypeSupport.add(mimeType); + } + + public String[] getSupportedLocales() { + return (String[]) localeSupport + .toArray(new String[localeSupport.size()]); + } + + public void addSupportedLocale(String locale) { + this.localeSupport.add(locale); + } + + public PortletInfoDD getPortletInfo() { + return portletInfo; + } + + public void setPortletInfo(PortletInfoDD dd) { + this.portletInfo = dd; + } + + public PortletPreferenceDD[] getPortletPreferences() { + return (PortletPreferenceDD[]) portletPreferences + .toArray(new PortletPreferenceDD[portletPreferences.size()]); + } + + public void addPortletPreference(PortletPreferenceDD dd) { + this.portletPreferences.add(dd); + } + + public String getPreferenceValidator() { + return this.preferencesValidator; + } + + public void setPreferenceValidator(String val) { + this.preferencesValidator = val; + } + + public void addSecurityRoleRef(SecurityRoleRefDD dd) { + this.securityRoleRef.add(dd); + } + + public SecurityRoleRefDD[] getSecurityRoleRefs() { + return (SecurityRoleRefDD[]) securityRoleRef.toArray( + new SecurityRoleRefDD[securityRoleRef.size()]); + } + + public String getResourceBundle() { + return resourceBundle; + } + + public void setResourceBundle(String resourceBundle) { + this.resourceBundle = resourceBundle; + } +}
diff --git a/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletInfoDD.java b/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletInfoDD.java new file mode 100644 index 0000000..8822af0 --- /dev/null +++ b/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletInfoDD.java
@@ -0,0 +1,55 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pluto.binding.impl.digester; + +import org.apache.pluto.binding.PortletInfoDD; + +/** + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 11, 2004 at 4:34:11 PM + */ +public class DigesterPortletInfoDD implements PortletInfoDD { + + private String title; + private String shortTitle; + private String keywords; + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getShortTitle() { + return shortTitle; + } + + public void setShortTitle(String shortTitle) { + this.shortTitle = shortTitle; + } + + public String getKeywords() { + return keywords; + } + + public void setKeywords(String keywords) { + this.keywords = keywords; + } +}
diff --git a/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletPreferenceDD.java b/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletPreferenceDD.java new file mode 100644 index 0000000..80206dc --- /dev/null +++ b/src/java/org/apache/pluto/binding/impl/digester/DigesterPortletPreferenceDD.java
@@ -0,0 +1,57 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pluto.binding.impl.digester; + +import org.apache.pluto.binding.PortletPreferenceDD; + +/** + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 11, 2004 at 4:38:36 PM + */ +public class DigesterPortletPreferenceDD implements PortletPreferenceDD { + + private String name; + private String value; + private boolean isReadOnly; + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public boolean isReadOnly() { + return isReadOnly; + } + + public void setReadOnly(boolean readOnly) { + isReadOnly = readOnly; + } + +}
diff --git a/src/java/org/apache/pluto/binding/impl/digester/DigesterSupportedMimeTypeDD.java b/src/java/org/apache/pluto/binding/impl/digester/DigesterSupportedMimeTypeDD.java new file mode 100644 index 0000000..ec51bc0 --- /dev/null +++ b/src/java/org/apache/pluto/binding/impl/digester/DigesterSupportedMimeTypeDD.java
@@ -0,0 +1,52 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.binding.impl.digester; + +import java.util.ArrayList; + +import org.apache.pluto.binding.SupportedMimeTypeDD; + +/** + * @author <a href="ddewolf@apache.org">David H. DeWolf</a> + * @version 1.0 + * @since Sep 20, 2004 + */ +public class DigesterSupportedMimeTypeDD implements SupportedMimeTypeDD { + + private String mimeType; + private ArrayList portletModes; + + public DigesterSupportedMimeTypeDD() { + portletModes = new ArrayList(); + } + + public String getMimeType() { + return mimeType; + } + + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + public String[] getPortletModes() { + return (String[]) portletModes.toArray(new String[portletModes.size()]); + } + + public void addPortletMode(String portletModes) { + this.portletModes.add(portletModes); + } +} +
diff --git a/src/java/org/apache/pluto/binding/impl/digester/DigesterXMLBindingFactory.java b/src/java/org/apache/pluto/binding/impl/digester/DigesterXMLBindingFactory.java new file mode 100644 index 0000000..25e1a50 --- /dev/null +++ b/src/java/org/apache/pluto/binding/impl/digester/DigesterXMLBindingFactory.java
@@ -0,0 +1,151 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.pluto.binding.impl.digester; + +import java.io.IOException; +import java.io.InputStream; + +import org.apache.commons.digester.Digester; +import org.apache.pluto.binding.PortletAppDD; +import org.apache.pluto.binding.WebAppDD; +import org.apache.pluto.binding.XMLBindingFactory; +import org.xml.sax.SAXException; + +/** + * ReadOnly implementation of XMLBindingFactory. + * @author <A href="mailto:ddewolf@apache.org">David H. DeWolf</A> + * @version 1.0 + * @since Mar 10, 2004 at 12:36:17 PM + */ +public class DigesterXMLBindingFactory extends XMLBindingFactory { + + private Digester wDigester; + private Digester pDigester; + + public DigesterXMLBindingFactory() { + this.wDigester = new Digester(); + this.pDigester = new Digester(); + init(); + } + + public int getMode() { + return XMLBindingFactory.READ_ONLY; + } + + public WebAppDD getWebAppDD(InputStream in) throws IOException { + try { + return (WebAppDD) wDigester.parse(in); + } catch (SAXException saxe) { + throw new IOException(saxe.getMessage()); + } + } + + public PortletAppDD getPortletAppDD(InputStream in) throws IOException { + try { + return (PortletAppDD) pDigester.parse(in); + } catch (SAXException saxe) { + throw new IOException(saxe.getMessage()); + } + } + + private void init() { + initWebDigester(); + initPortletDigester(); + } + + private void initWebDigester() { + wDigester.setValidating(false); + + } + + private void initPortletDigester() { + pDigester.setValidating(false); + pDigester.addObjectCreate("portlet-app", DigesterPortletAppDD.class); + + // ** Portlet Entity ** // + pDigester.addObjectCreate("portlet-app/portlet", + DigesterPortletDD.class); + pDigester.addBeanPropertySetter("portlet-app/portlet/description", + "description"); + pDigester.addBeanPropertySetter("portlet-app/portlet/portlet-name", + "portletName"); + pDigester.addBeanPropertySetter("portlet-app/portlet/display-name", + "displayName"); + pDigester.addBeanPropertySetter("portlet-app/portlet/portlet-class", + "portletClass"); + + // ** Init Parameter ** // + pDigester.addObjectCreate("portlet-app/portlet/init-param", + DigesterInitParameterDD.class); + pDigester.addBeanPropertySetter("portlet-app/portlet/init-param/name", + "parameterName"); + pDigester.addBeanPropertySetter("portlet-app/portlet/init-param/value", + "parameterValue"); + pDigester.addBeanPropertySetter( + "portlet-app/portlet/init-param/description", "description"); + pDigester.addSetNext("portlet-app/portlet/init-param", + "addInitParameter"); + + pDigester.addBeanPropertySetter("portlet-app/portlet/expiration-cache", + "expirationCache"); + pDigester.addBeanPropertySetter("portlet-app/portlet/resource-bundle", + "resourceBundle"); + + + pDigester.addObjectCreate("portlet-app/portlet/portlet-info", + DigesterPortletInfoDD.class); + pDigester.addBeanPropertySetter( + "portlet-app/portlet/portlet-info/title", "title"); + pDigester.addBeanPropertySetter( + "portlet-app/portlet/portlet-info/short-title", "shortTitle"); + pDigester.addBeanPropertySetter( + "portlet-app/portlet/portlet-info/keywords", "keywords"); + pDigester.addSetNext("portlet-app/portlet/portlet-info", + "setPortletInfo"); + + pDigester.addObjectCreate( + "portlet-app/portlet/portlet-preferences/preference", + DigesterPortletPreferenceDD.class); + pDigester.addBeanPropertySetter( + "portlet-app/portlet/portlet-preferences/preference/name", "name"); + pDigester.addBeanPropertySetter( + "portlet-app/portlet/portlet-preferences/preference/value", + "value"); + pDigester.addBeanPropertySetter( + "portlet-app/portlet/portlet-preferences/preference/read-only", + "readOnly"); + pDigester.addSetNext( + "portlet-app/portlet/portlet-preferences/preference", + "addPortletPreference"); + + + // ** Supports ** // + pDigester.addObjectCreate("portlet-app/portlet/supports", + DigesterSupportedMimeTypeDD.class); + pDigester.addBeanPropertySetter( + "portlet-app/portlet/supports/mime-type", "mimeType"); + pDigester.addCallMethod("portlet-app/portlet/supports/portlet-mode", + "addPortletMode", 0); + pDigester.addSetNext("portlet-app/portlet/supports", + "addSupportedMimeType"); + + //** Supported Locale ** // + pDigester.addCallMethod("portlet-app/portlet/supported-locale", + "addSupportedLocale", 0); + pDigester.addSetNext("portlet-app/portlet", "addPortlet"); + } +}
diff --git a/src/java/org/apache/pluto/binding/package.html b/src/java/org/apache/pluto/binding/package.html new file mode 100644 index 0000000..e826f36 --- /dev/null +++ b/src/java/org/apache/pluto/binding/package.html
@@ -0,0 +1,5 @@ +<HTML> +<BODY> +Abstraction of the object model representing common +deployment descriptors used by Pluto. +</BODY> \ No newline at end of file