Author: taylor
Date: Tue Dec 19 11:11:11 2006
New Revision: 488764
URL: http://svn.apache.org/viewvc?view=rev&rev=488764
Log:
RegistrationTool
use this tool to register portlet apps from the command line
this is a bootstrap implementation that we are using for testing the
multithreaded aggregator
right now it is only integrated into the Maven-1 build
Will revisit the Maven-2 build after we refine this process
Added:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/registration/
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java
portals/jetspeed-2/trunk/etc/registration/
portals/jetspeed-2/trunk/etc/registration/assembly/
portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml
portals/jetspeed-2/trunk/etc/registration/registration.properties
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java?view=diff&rev=488764&r1=488763&r2=488764
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
(original)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
Tue Dec 19 11:11:11 2006
@@ -47,6 +47,7 @@
public JetspeedRequestContextComponent(String contextClassName)
{
+ this.contextClassName = contextClassName;
}
public JetspeedRequestContextComponent(String contextClassName,
Added:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java?view=auto&rev=488764
==============================================================================
---
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java
(added)
+++
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/tools/registration/RegistrationTool.java
Tue Dec 19 11:11:11 2006
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2000-2001,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.jetspeed.tools.registration;
+
+import java.io.File;
+import java.io.FileReader;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.engine.JetspeedEngineConstants;
+import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
+import org.apache.jetspeed.om.common.portlet.PortletApplication;
+import org.apache.jetspeed.om.common.servlet.MutableWebApplication;
+import org.apache.jetspeed.util.descriptor.PortletApplicationDescriptor;
+import org.apache.jetspeed.util.descriptor.WebApplicationDescriptor;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * <p>
+ * OjbPortletRegistry
+ * </p>
+ * <p>
+ *
+ * </p>
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver </a>
+ * @version $Id: PersistenceBrokerPortletRegistry.java 225622 2005-07-27
20:39:14Z weaver $
+ *
+ */
+public class RegistrationTool
+{
+ private PortletRegistry registry;
+ private boolean overwriteApps = true;
+
+ public static void main(String args[])
+ {
+ String fileName =
System.getProperty("org.apache.jetspeed.portletregistry.configuration",
"registration.properties");
+ PropertiesConfiguration configuration = new PropertiesConfiguration();
+ try
+ {
+ File appRootDir = new File("./src/webapp");
+ System.setProperty(JetspeedEngineConstants.APPLICATION_ROOT_KEY,
appRootDir.getAbsolutePath());
+ configuration.load(fileName);
+ String [] bootAssemblies =
configuration.getStringArray("boot.assemblies");
+ String [] assemblies = configuration.getStringArray("assemblies");
+ ClassPathXmlApplicationContext ctx;
+
+ if (bootAssemblies != null)
+ {
+ ApplicationContext bootContext = new
ClassPathXmlApplicationContext(bootAssemblies, true);
+ ctx = new ClassPathXmlApplicationContext(assemblies, true,
bootContext);
+ }
+ else
+ {
+ ctx = new ClassPathXmlApplicationContext(assemblies, true);
+ }
+
+ boolean overwriteApps = configuration.getBoolean("overwrite.apps",
true);
+ String registryBean =
configuration.getString("registry.component", "");
+ String[] appNames = configuration.getStringArray("apps");
+ String[] appDescriptors =
configuration.getStringArray("descriptors");
+ String[] webappDescriptors =
configuration.getStringArray("webapp.descriptors");
+
+ PortletRegistry registry =
(PortletRegistry)ctx.getBean(registryBean);
+ RegistrationTool tool = new RegistrationTool(registry,
overwriteApps);
+
+ for (int ix=0; ix < appNames.length; ix++)
+ {
+ if (overwriteApps)
+ {
+ tool.unregister(appNames[ix]);
+ }
+ tool.register(appNames[ix], appDescriptors[ix],
webappDescriptors[ix]);
+ }
+ }
+ catch (Exception e)
+ {
+ System.err.println("Failed to import: " + e);
+ e.printStackTrace();
+ }
+
+ }
+
+ public RegistrationTool(PortletRegistry registry, boolean overwriteApps)
+ {
+ this.registry = registry;
+ this.overwriteApps = overwriteApps;
+ }
+
+ public void unregister(String appName)
+ throws Exception
+ {
+ if (registry.portletApplicationExists(appName))
+ {
+ PortletApplication app = registry.getPortletApplication(appName);
+ if (app != null)
+ {
+ registry.removeApplication(app);
+ }
+ }
+ }
+
+ public void register(String appName, String appDescriptor, String
webappDescriptor)
+ throws Exception
+ {
+ WebApplicationDescriptor wad = new WebApplicationDescriptor(new
FileReader(webappDescriptor), "/" + appName);
+ MutableWebApplication webapp = wad.createWebApplication();
+ PortletApplicationDescriptor pad = new
PortletApplicationDescriptor(new FileReader(appDescriptor), appName);
+ MutablePortletApplication app = pad.createPortletApplication();
+ app.setWebApplicationDefinition(webapp);
+ registry.registerPortletApplication(app);
+ }
+}
\ No newline at end of file
Added: portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml?view=auto&rev=488764
==============================================================================
--- portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml (added)
+++ portals/jetspeed-2/trunk/etc/registration/assembly/registry.xml Tue Dec 19
11:11:11 2006
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
+<!--
+ 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.
+-->
+<beans>
+
+ <!-- Portlet Factory -->
+ <bean id="portletFactory"
class="org.apache.jetspeed.factory.JetspeedPortletFactory"></bean>
+
+ <!-- Portlet Registry DAO-->
+ <bean id="portletRegistryImpl"
class="org.apache.jetspeed.components.portletregistry.PersistenceBrokerPortletRegistry"
init-method="init">
+
+ <constructor-arg index="0">
+ <value>JETSPEED-INF/ojb/registry_repository.xml</value>
+ </constructor-arg>
+ <constructor-arg index="1">
+ <ref bean="portletFactory" />
+ </constructor-arg>
+ </bean>
+
+ <bean id="org.apache.jetspeed.components.portletregistry.PortletRegistry"
name="portletRegistry" parent="baseTransactionProxy">
+ <property name="proxyInterfaces">
+
<value>org.apache.jetspeed.components.portletregistry.PortletRegistry</value>
+ </property>
+
+ <property name="target">
+ <ref bean="portletRegistryImpl" />
+ </property>
+ <property name="transactionAttributes">
+ <props>
+ <prop
key="register*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+ <prop
key="remove*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+ <prop
key="update*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+ <prop
key="save*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletregistry.RegistryException</prop>
+ <prop key="*">PROPAGATION_SUPPORTS</prop>
+ </props>
+ </property>
+ </bean>
+
+ <bean id="portletEntityAccessImpl"
class="org.apache.jetspeed.components.portletentity.PersistenceBrokerPortletEntityAccess"
+ name="portletEntityAccessImpl">
+ <constructor-arg>
+ <ref bean="portletRegistry" />
+ </constructor-arg>
+ </bean>
+
+ <bean
id="org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"
parent="baseTransactionProxy" name="portletEntityAccess">
+ <property name="proxyInterfaces">
+
<value>org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent</value>
+ </property>
+ <property name="target">
+ <ref bean="portletEntityAccessImpl" />
+ </property>
+ <!--
+ <property name="preInterceptors">
+ <list>
+ <ref bean="portletEntityCachingAdvisor"/>
+ <ref bean="portletEntityRemoveFromCacheAdvisor"/>
+ </list>
+ </property>
+ -->
+ <property name="transactionAttributes">
+ <props>
+ <prop key="remove*">PROPAGATION_REQUIRED</prop>
+ <prop
key="store*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException</prop>
+ <prop key="*">PROPAGATION_SUPPORTS</prop>
+ </props>
+ </property>
+ </bean>
+
+ <!-- Inject Portlet Entity Proxy into Portlet Entity impl -->
+ <bean id="injectEntityAccessProxy"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+ <property name="targetObject"><ref
bean="portletEntityAccessImpl"/></property>
+ <property
name="targetMethod"><value>setEntityAccessProxy</value></property>
+ <property name="arguments">
+ <list>
+ <ref
bean="org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent"/>
+ </list>
+ </property>
+ </bean>
+
+</beans>
\ No newline at end of file
Added: portals/jetspeed-2/trunk/etc/registration/registration.properties
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/etc/registration/registration.properties?view=auto&rev=488764
==============================================================================
--- portals/jetspeed-2/trunk/etc/registration/registration.properties (added)
+++ portals/jetspeed-2/trunk/etc/registration/registration.properties Tue Dec
19 11:11:11 2006
@@ -0,0 +1,16 @@
+# comma-separated list of boot assemblies for Spring
+boot.assemblies = repository-datasource-spring.xml
+# comma-separated list of assemblies for Spring
+assemblies = registry.xml, transaction.xml
+# overwrite portlet applications flag, set to true to replace existing portlet
applications
+overwrite.apps = true
+# registry component name
+registry.component =
org.apache.jetspeed.components.portletregistry.PortletRegistry
+# apps to register
+apps = demo, j2-admin
+# app descriptor locations
+descriptors = ./applications/demo/src/webapp/WEB-INF/portlet.xml,
./applications/j2-admin/src/webapp/WEB-INF/portlet.xml
+# webapp descriptor locations
+webapp.descriptors = ./applications/demo/src/webapp/WEB-INF/web.xml,
./applications/j2-admin/src/webapp/WEB-INF/web.xml
+
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]