You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by rw...@apache.org on 2009/01/19 21:39:40 UTC
svn commit: r735797 [2/3] - in
/portals/jetspeed-2/portal/branches/JPA_BRANCH:
components/jetspeed-capability/src/main/java/org/apache/jetspeed/capabilities/jpa/
components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/page/jpa/
components/je...
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/PrincipalRuleImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/PrincipalRuleImpl.java?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/PrincipalRuleImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/PrincipalRuleImpl.java Mon Jan 19 12:39:38 2009
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.profiler.rules.jpa;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.PrePersist;
+import javax.persistence.PostLoad;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.profiler.rules.PrincipalRule;
+import org.apache.jetspeed.profiler.rules.ProfilingRule;
+
+
+/**
+ * PrincipalRuleImpl
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: PrincipalRuleImpl.java 516448 2007-03-09 16:25:47Z ate $
+ */
+@Entity (name="PrincipalRule")
+@IdClass (value=PrincipalRuleImpl.PrincipalRuleImplId.class)
+@Table (name="PRINCIPAL_RULE_ASSOC")
+@NamedQueries({@NamedQuery(name="PRINCIPAL_RULE", query="select pr from PrincipalRule pr where pr.principalName = :principalName and pr.locatorName = :locatorName"),
+ @NamedQuery(name="PRINCIPAL_RULES", query="select pr from PrincipalRule pr where pr.principalName = :principalName")})
+public class PrincipalRuleImpl implements PrincipalRule
+{
+ private static final long serialVersionUID = 1;
+
+ // Members
+
+ @Id
+ @Column (name="PRINCIPAL_NAME")
+ private String principalName;
+ @Id
+ @Column (name="LOCATOR_NAME")
+ private String locatorName;
+ @Version
+ @Column (name="JPA_VERSION")
+ private int jpaVersion;
+ @ManyToOne (targetEntity=AbstractProfilingRule.class, fetch=FetchType.LAZY, optional=true, cascade=CascadeType.PERSIST)
+ @JoinColumn (name="RULE_ID", referencedColumnName="RULE_ID")
+ private ProfilingRule profilingRule;
+
+ @PostLoad
+ private void postLoad()
+ {
+ isNew = false;
+ }
+ @PrePersist
+ private void prePersist()
+ {
+ isNew = false;
+ }
+
+ @Transient
+ private boolean isNew = true;
+
+ public static class PrincipalRuleImplId
+ {
+ public String principalName;
+ public String locatorName;
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (!(o instanceof PrincipalRuleImplId))
+ {
+ return false;
+ }
+ PrincipalRuleImplId other = (PrincipalRuleImplId)o;
+ return (((principalName == other.principalName) || ((principalName != null) && principalName.equals(other.principalName))) &&
+ ((locatorName == other.locatorName) || ((locatorName != null) && locatorName.equals(other.locatorName))));
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode()
+ {
+ return ((principalName != null) ? principalName.hashCode() : 0)^((locatorName != null) ? locatorName.hashCode() : 0);
+ }
+ }
+
+ // Implementation
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.PrincipalRule#getPrincipalName()
+ */
+ public String getPrincipalName()
+ {
+ return this.principalName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.PrincipalRule#setPrincipalName(java.lang.String)
+ */
+ public void setPrincipalName(String name)
+ {
+ this.principalName = name;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.PrincipalRule#getProfilingRule()
+ */
+ public ProfilingRule getProfilingRule()
+ {
+ return this.profilingRule;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.PrincipalRule#setProfilingRule(org.apache.jetspeed.profiler.rules.ProfilingRule)
+ */
+ public void setProfilingRule(ProfilingRule rule)
+ {
+ this.profilingRule = rule;
+ }
+
+ /**
+ * @return Returns the locatorName.
+ */
+ public String getLocatorName()
+ {
+ return locatorName;
+ }
+ /**
+ * @param locatorName The locatorName to set.
+ */
+ public void setLocatorName(String locatorName)
+ {
+ this.locatorName = locatorName;
+ }
+
+ /**
+ * Get new persistent status.
+ *
+ * @return whether object is new.
+ */
+ public boolean isNew()
+ {
+ return isNew;
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RoleFallbackProfilingRule.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RoleFallbackProfilingRule.java?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RoleFallbackProfilingRule.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RoleFallbackProfilingRule.java Mon Jan 19 12:39:38 2009
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.profiler.rules.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.apache.jetspeed.profiler.ProfileLocator;
+import org.apache.jetspeed.profiler.Profiler;
+import org.apache.jetspeed.profiler.rules.ProfileResolvers;
+import org.apache.jetspeed.profiler.rules.ProfilingRule;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * RoleFallbackProfilingRule
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: RoleFallbackProfilingRule.java 726976 2008-12-16 07:15:50Z taylor $
+ */
+@Entity (name="RoleFallbackProfilingRule")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="PROFILING_RULE")
+@DiscriminatorColumn (name="CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule")
+public class RoleFallbackProfilingRule extends AbstractProfilingRule implements ProfilingRule
+{
+ private final static long serialVersionUID = 1L;
+
+ public RoleFallbackProfilingRule()
+ {
+ }
+
+ public RoleFallbackProfilingRule(ProfileResolvers resolvers)
+ {
+ super(resolvers);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.ProfilingRule#apply(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.profiler.Profiler)
+ */
+ public ProfileLocator apply(RequestContext context, Profiler service)
+ {
+ return applyRoleFallbackProfilingRule(context, service);
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionImpl.java?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionImpl.java Mon Jan 19 12:39:38 2009
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.profiler.rules.jpa;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Version;
+
+import org.apache.jetspeed.profiler.rules.RuleCriterion;
+
+/**
+ * RuleCriterionImpl
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: RuleCriterionImpl.java 646620 2008-04-10 02:45:45Z ate $
+ */
+@Entity (name="RuleCriterion")
+@Table (name="RULE_CRITERION")
+public class RuleCriterionImpl implements RuleCriterion
+{
+ private static final long serialVersionUID = 1;
+
+ // Members
+
+ @Id
+ @GeneratedValue (strategy=GenerationType.AUTO)
+ @Column (name="CRITERION_ID")
+ private int id;
+ @Version
+ @Column (name="JPA_VERSION")
+ private int jpaVersion;
+ @ManyToOne (targetEntity=AbstractProfilingRule.class, fetch=FetchType.LAZY, optional=false)
+ @JoinColumn (name="RULE_ID", referencedColumnName="RULE_ID")
+ private AbstractProfilingRule rule;
+ @Basic
+ @Column (name="REQUEST_TYPE")
+ private String type;
+ @Basic
+ @Column (name="NAME")
+ private String name;
+ @Basic
+ @Column (name="COLUMN_VALUE")
+ private String value;
+ @Basic
+ @Column (name="FALLBACK_TYPE")
+ private int fallbackType;
+ @Basic
+ @Column (name="FALLBACK_ORDER")
+ private int fallbackOrder;
+
+ /**
+ * Explicitly set inverse relationship when this object
+ * is added to a one-to-many collection. JPA does not
+ * manage bidirectional relationships.
+ *
+ * @param inverse inverse relationship owning object.
+ */
+ public void setInverseRelationship(Object inverse)
+ {
+ rule = (AbstractProfilingRule)inverse;
+ }
+
+ // Constructors
+
+ public RuleCriterionImpl()
+ {
+ fallbackType = RuleCriterion.FALLBACK_CONTINUE;
+ }
+
+ public RuleCriterionImpl(RuleCriterion master)
+ {
+ this.name = master.getName();
+ this.type = master.getType();
+ this.value = master.getValue();
+ this.fallbackOrder = master.getFallbackOrder();
+ this.fallbackType = master.getFallbackType();
+ }
+
+ // Implementation
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object o)
+ {
+ // two objects of type RuleCriterion should be considered equal if their name and type are the same
+ if (this == o) return true;
+ if ((o == null) || (!(o instanceof RuleCriterion)))
+ return false;
+ RuleCriterion r = (RuleCriterion)o;
+ if (this.name != null)
+ {
+ if (!(this.name.equals(r.getName())))
+ return false;
+ }
+ else
+ if (r.getName() != null)
+ return false;
+ if (this.type != null)
+ {
+ if (!(this.type.equals(r.getType())))
+ return false;
+ }
+ else
+ if (r.getType() != null)
+ return false;
+ return true;
+
+ }
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getType()
+ */
+ public String getType()
+ {
+ return this.type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setType(java.lang.String)
+ */
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getName()
+ */
+ public String getName()
+ {
+ return this.name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setName(java.lang.String)
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getFallbackOrder()
+ */
+ public int getFallbackOrder()
+ {
+ return fallbackOrder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getValue()
+ */
+ public String getValue()
+ {
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setFallbackOrder(int)
+ */
+ public void setFallbackOrder(int i)
+ {
+ fallbackOrder = i;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setValue(java.lang.String)
+ */
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#getFallbackType()
+ */
+ public int getFallbackType()
+ {
+ return fallbackType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.RuleCriterion#setFallbackType(int)
+ */
+ public void setFallbackType(int i)
+ {
+ fallbackType = i;
+ }
+
+ /**
+ * Get new persistent status.
+ *
+ * @return whether object is new.
+ */
+ public boolean isNew()
+ {
+ return (id == 0);
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionList.java?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionList.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/RuleCriterionList.java Mon Jan 19 12:39:38 2009
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.profiler.rules.jpa;
+
+import java.util.AbstractList;
+import java.util.List;
+
+import org.apache.jetspeed.profiler.rules.RuleCriterion;
+
+/**
+ * RuleCriterionList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class RuleCriterionList extends AbstractList<RuleCriterion>
+{
+ private AbstractProfilingRule profilingRule;
+ private List<RuleCriterion> criterionList;
+
+ RuleCriterionList(AbstractProfilingRule profilingRule, List<RuleCriterion> criterionList)
+ {
+ super();
+ this.profilingRule = profilingRule;
+ this.criterionList = criterionList;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#add(int,java.lang.Object)
+ */
+ public synchronized void add(int index, RuleCriterion element)
+ {
+ // implement for modifiable AbstractList:
+ // validate index
+ if ((index < 0) || (index > criterionList.size()))
+ {
+ throw new IndexOutOfBoundsException("Unable to add to list at index: " + index);
+ }
+ // add to underlying ordered list
+ RuleCriterionImpl criterionElement = (RuleCriterionImpl)element;
+ criterionElement.setInverseRelationship(profilingRule);
+ criterionList.add(index, criterionElement);
+ // set element order in added element
+ if (index > 0)
+ {
+ criterionElement.setFallbackOrder(criterionList.get(index-1).getFallbackOrder() + 1);
+ }
+ else
+ {
+ criterionElement.setFallbackOrder(0);
+ }
+ // maintain element order in subsequent elements
+ for (int i = index, limit = criterionList.size() - 1; (i < limit); i++)
+ {
+ RuleCriterionImpl nextCriterionElement = (RuleCriterionImpl)criterionList.get(i + 1);
+ if (nextCriterionElement.getFallbackOrder() <= criterionElement.getFallbackOrder())
+ {
+ // adjust element order for next element
+ nextCriterionElement.setFallbackOrder(criterionElement.getFallbackOrder() + 1);
+ criterionElement = nextCriterionElement;
+ }
+ else
+ {
+ // element order maintained for remaining list elements
+ break;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#get(int)
+ */
+ public synchronized RuleCriterion get(int index)
+ {
+ // implement for modifiable AbstractList
+ return criterionList.get(index);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#remove(int)
+ */
+ public synchronized RuleCriterion remove(int index)
+ {
+ // implement for modifiable AbstractList
+ RuleCriterionImpl removed = (RuleCriterionImpl)criterionList.remove(index);
+ if (removed != null)
+ {
+ removed.setInverseRelationship(null);
+ }
+ return removed;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#set(int,java.lang.Object)
+ */
+ public synchronized RuleCriterion set(int index, RuleCriterion element)
+ {
+ // implement for modifiable AbstractList:
+ // set in underlying ordered list
+ RuleCriterionImpl newCriterionElement = (RuleCriterionImpl)element;
+ newCriterionElement.setInverseRelationship(profilingRule);
+ RuleCriterionImpl criterionElement = (RuleCriterionImpl)criterionList.set(index, newCriterionElement);
+ criterionElement.setInverseRelationship(null);
+ // set element order in new element
+ newCriterionElement.setFallbackOrder(criterionElement.getFallbackOrder());
+ // return element
+ return criterionElement;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#size()
+ */
+ public synchronized int size()
+ {
+ // implement for modifiable AbstractList
+ return criterionList.size();
+ }
+}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/StandardProfilingRule.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/StandardProfilingRule.java?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/StandardProfilingRule.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/profiler/rules/jpa/StandardProfilingRule.java Mon Jan 19 12:39:38 2009
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.profiler.rules.jpa;
+
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.apache.jetspeed.profiler.ProfileLocator;
+import org.apache.jetspeed.profiler.Profiler;
+import org.apache.jetspeed.profiler.rules.ProfileResolvers;
+import org.apache.jetspeed.profiler.rules.ProfilingRule;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * StandardProfilingRule applies the standard Jetspeed-1 profiling rules.
+ * The result is an ordered list of Profile Locator name/value pairs.
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: StandardProfilingRule.java 516448 2007-03-09 16:25:47Z ate $
+ */
+@Entity (name="StandardProfilingRule")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="PROFILING_RULE")
+@DiscriminatorColumn (name="CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule")
+public class StandardProfilingRule extends AbstractProfilingRule implements ProfilingRule
+{
+ private static final long serialVersionUID = 1;
+
+ public StandardProfilingRule()
+ {
+ }
+
+ public StandardProfilingRule(ProfileResolvers resolvers)
+ {
+ super(resolvers);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.rules.ProfilingRule#apply(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.profiler.Profiler)
+ */
+ public ProfileLocator apply(RequestContext context, Profiler service)
+ {
+ return applyStandardProfilingRule(context, service);
+ }
+}
\ No newline at end of file
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/java/org/apache/jetspeed/serializer/JetspeedProfilerSerializer.java Mon Jan 19 12:39:38 2009
@@ -144,7 +144,7 @@
catch (Exception e)
{
throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(
- "org.apache.jetspeed.capabilities.Capabilities", e.getLocalizedMessage()));
+ "org.apache.jetspeed.profiler.rules.ProfilingRule", e.getLocalizedMessage()), e);
}
}
/** reset the default profiling rule */
@@ -230,7 +230,6 @@
c.setName(jsr.getName());
c.setType(jsr.getType());
c.setValue(jsr.getValue());
- c.setRuleId(rule.getId());
return c;
}
catch (Exception e)
@@ -313,7 +312,7 @@
catch (Exception e)
{
throw new SerializerException(SerializerException.CREATE_OBJECT_FAILED.create(new String[] {
- "Standard Rule", e.getMessage() }));
+ "Standard Rule", e.getMessage() }), e);
}
Iterator list = null;
@@ -324,7 +323,7 @@
catch (Exception e)
{
throw new SerializerException(SerializerException.GET_EXISTING_OBJECTS.create(new String[] {
- "ProfilingRules", e.getMessage() }));
+ "ProfilingRules", e.getMessage() }), e);
}
while (list.hasNext())
{
@@ -342,7 +341,7 @@
catch (Exception e)
{
throw new SerializerException(SerializerException.CREATE_SERIALIZED_OBJECT_FAILED.create(new String[] {
- "ProfilingRules", e.getMessage() }));
+ "ProfilingRules", e.getMessage() }), e);
}
}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/resources/META-INF/persistence.xml?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/resources/META-INF/persistence.xml (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/main/resources/META-INF/persistence.xml Mon Jan 19 12:39:38 2009
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+ <persistence-unit name="jetspeed-profiler" transaction-type="JTA">
+
+ <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+
+ <jta-data-source>jetspeed-xa</jta-data-source>
+ <non-jta-data-source>jetspeed</non-jta-data-source>
+
+ <class>org.apache.jetspeed.profiler.rules.jpa.AbstractProfilingRule</class>
+ <class>org.apache.jetspeed.profiler.rules.jpa.PrincipalRuleImpl</class>
+ <class>org.apache.jetspeed.profiler.rules.jpa.RoleFallbackProfilingRule</class>
+ <class>org.apache.jetspeed.profiler.rules.jpa.RuleCriterionImpl</class>
+ <class>org.apache.jetspeed.profiler.rules.jpa.StandardProfilingRule</class>
+
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+
+ </persistence-unit>
+
+</persistence>
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestOpenJPAProfiler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestOpenJPAProfiler.java?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestOpenJPAProfiler.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestOpenJPAProfiler.java Mon Jan 19 12:39:38 2009
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.profiler;
+
+import junit.framework.Test;
+
+import org.apache.jetspeed.profiler.jpa.ProfilerManagerContext;
+import org.apache.jetspeed.profiler.rules.jpa.RoleFallbackProfilingRule;
+import org.apache.jetspeed.profiler.rules.jpa.StandardProfilingRule;
+
+/**
+ * TestOpenJPAProfiler
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+public class TestOpenJPAProfiler extends TestProfiler
+{
+ private ProfilerManagerContext context;
+
+ /**
+ * Define ordered test case test methods.
+ *
+ * @return test suite
+ */
+ public static Test suite()
+ {
+ return createFixturedTestSuite(TestOpenJPAProfiler.class, "firstTestSetup", "lastTestTeardown");
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.TestProfiler#getConfigurations()
+ */
+ protected String[] getConfigurations()
+ {
+ return new String[] {"openjpa-profiler.xml", "transaction.xml", "serializer.xml", "security-providers.xml", "cache-test.xml", "capabilities.xml", "registry.xml", "search.xml", "jetspeed-spring.xml",
+ "security-managers.xml", "security-spi.xml", "security-spi-atn.xml", "security-atz.xml", "static-bean-references.xml" };
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.TestProfiler#getBeanDefinitionFilterCategories()
+ */
+ protected String getBeanDefinitionFilterCategories()
+ {
+ return "security,serializer,registry,search,capabilities,dbSecurity,transaction,cache,noRequestContext,jdbcDS";
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.components.util.jpa.JPADatasourceEnabledSpringTestCase#startConversationalTxn()
+ */
+ protected void startConversationalTxn()
+ {
+ // create scoped context bean for thread transaction
+ context = (ProfilerManagerContext)scm.createPrototypeComponent("profilerManagerContext");
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.components.util.jpa.JPADatasourceEnabledSpringTestCase#endConversationalTxn()
+ */
+ protected void endConversationalTxn()
+ {
+ // destroy scoped context bean for thread transaction
+ scm.destroyPrototypeComponent("profilerManagerContext", context);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.TestProfiler#getStandardProfilingRuleClass()
+ */
+ protected Class getStandardProfilingRuleClass()
+ {
+ return StandardProfilingRule.class;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.profiler.TestProfiler#getRoleFallbackProfilingRuleClass()
+ */
+ protected Class getRoleFallbackProfilingRuleClass()
+ {
+ return RoleFallbackProfilingRule.class;
+ }
+
+ /**
+ * Start the tests.
+ *
+ * @param args the arguments. Not used
+ */
+ public static void main(String args[])
+ {
+ junit.awtui.TestRunner.main(new String[]{TestOpenJPAProfiler.class.getName()});
+ }
+}
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/java/org/apache/jetspeed/profiler/TestProfiler.java Mon Jan 19 12:39:38 2009
@@ -31,7 +31,7 @@
import junit.framework.Test;
-import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
+import org.apache.jetspeed.components.util.jpa.JPADatasourceEnabledSpringTestCase;
import org.apache.jetspeed.mockobjects.request.MockRequestContext;
import org.apache.jetspeed.profiler.impl.JetspeedProfilerImpl;
import org.apache.jetspeed.profiler.rules.ProfileResolvers;
@@ -52,31 +52,65 @@
* @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
* @version $Id$
*/
-public class TestProfiler extends DatasourceEnabledSpringTestCase
+public class TestProfiler extends JPADatasourceEnabledSpringTestCase
{
+ // Constants
+
+ private static final String DEFAULT_RULE = "j1";
+
+ private static final String FALLBACK_RULE = "role-fallback";
+
+ private static final int EXPECTED_STANDARD = 1;
+
+ private static final int EXPECTED_FALLBACK = 1;
+
+ private static final String DEFAULT_PAGE = "default-page";
+
+ private static final String URF_CRITERIA [] =
+ {
+ "user",
+ "navigation",
+ "role",
+ "path.session"
+ };
+
+ private static final String URCF_CRITERIA [] =
+ {
+ "user",
+ "navigation",
+ "rolecombo",
+ "path.session"
+ };
+
+ // Members
+
private Profiler profiler = null;
private ProfileResolvers resolvers = null;
- protected static final Properties TEST_PROPS = new Properties();
-
- static
+ // Implementation
+
+ /**
+ * Define ordered test case test methods.
+ *
+ * @return test suite
+ */
+ public static Test suite()
{
- TEST_PROPS.put("defaultRule", "j1");
- TEST_PROPS.put("anonymousUser", "anon");
- TEST_PROPS.put("locator.impl", "org.apache.jetspeed.profiler.impl.JetspeedProfileLocator");
- TEST_PROPS.put("principalRule.impl", "org.apache.jetspeed.profiler.rules.impl.PrincipalRuleImpl");
- TEST_PROPS.put("profilingRule.impl", "org.apache.jetspeed.profiler.rules.impl.AbstractProfilingRule");
+ return createFixturedTestSuite(TestProfiler.class, "firstTestSetup", "lastTestTeardown");
}
- /**
+ /* (non-Javadoc)
+ *
* Override the location of the test properties by using the jetspeed properties found in the default package.
* Make sure to have your unit test copy in jetspeed properties into the class path root like:
- <blockquote><pre>
- <resource>
- <path>conf/jetspeed</path>
- <include>*.properties</include>
- </resource>
- </pre></blockquote>
+ * <blockquote><pre>
+ * <resource>
+ * <path>conf/jetspeed</path>
+ * <include>*.properties</include>
+ * </resource>
+ * </pre></blockquote>
+ *
+ * @see org.apache.jetspeed.components.test.AbstractSpringTestCase#getInitProperties()
*/
@Override
protected Properties getInitProperties()
@@ -87,7 +121,8 @@
InputStream is = this.getClass().getClassLoader().getResourceAsStream("jetspeed.properties");
if (is != null)
props.load(is);
- } catch (FileNotFoundException e)
+ }
+ catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
@@ -100,61 +135,59 @@
return props;
}
- /**
- * Start the tests.
- *
- * @param args
- * the arguments. Not used
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.components.util.jpa.JPADatasourceEnabledSpringTestCase#setUp()
*/
- public static void main(String args[])
- {
- junit.awtui.TestRunner.main(new String[]
- { TestProfiler.class.getName() });
- }
-
-
protected void setUp() throws Exception
{
super.setUp();
- this.profiler = (Profiler) scm.getComponent("profiler");
- JetspeedProfilerImpl profilerImpl = (JetspeedProfilerImpl)scm.getComponent("profilerImpl");
+ profiler = (Profiler)scm.getComponent("profiler");
+ Profiler profilerImpl = (Profiler)scm.getComponent("profilerImpl");
assertNotNull("profiler not found ", profiler);
ProfileResolvers resolvers = (ProfileResolvers)scm.getComponent("ProfileResolvers");
assertNotNull("resolvers not found ", resolvers);
profilerImpl.setDefaultRule(JetspeedProfilerImpl.DEFAULT_RULE);
}
-
- public static Test suite()
+
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.components.test.AbstractSpringTestCase#getConfigurations()
+ */
+ protected String[] getConfigurations()
{
- return createFixturedTestSuite(TestProfiler.class, "firstTestSetup", "lastTestTeardown");
+ return new String[] { "profiler.xml", "transaction.xml", "serializer.xml", "security-providers.xml", "cache-test.xml", "capabilities.xml", "registry.xml", "search.xml", "jetspeed-spring.xml",
+ "security-managers.xml", "security-spi.xml", "security-spi-atn.xml", "security-atz.xml", "static-bean-references.xml" };
}
- private static final String DEFAULT_RULE = "j1";
-
- private static final String FALLBACK_RULE = "role-fallback";
-
- private static final int EXPECTED_STANDARD = 1;
-
- private static final int EXPECTED_FALLBACK = 1;
-
- private static final String DEFAULT_PAGE = "default-page";
-
- private static final String URF_CRITERIA [] =
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase#getBeanDefinitionFilterCategories()
+ */
+ protected String getBeanDefinitionFilterCategories()
{
- "user",
- "navigation",
- "role",
- "path.session"
- };
-
- private static final String URCF_CRITERIA [] =
+ return "security,serializer,registry,search,capabilities,profiler,dbSecurity,transaction,cache,noRequestContext,jdbcDS";
+ }
+
+ /**
+ * Get StandardProfilingRule implementation class.
+ *
+ * @return implementation class.
+ */
+ protected Class getStandardProfilingRuleClass()
{
- "user",
- "navigation",
- "rolecombo",
- "path.session"
- };
-
+ return StandardProfilingRule.class;
+ }
+
+ /**
+ * Get RoleFallbackProfilingRule implementation class.
+ *
+ * @return implementation class.
+ */
+ protected Class getRoleFallbackProfilingRuleClass()
+ {
+ return RoleFallbackProfilingRule.class;
+ }
+
+ // Test Methods
public void firstTestSetup() throws Exception
{
@@ -171,8 +204,7 @@
serializer.deleteData();
}
- public void testUserRoleFallback()
- throws Exception
+ public void testUserRoleFallback() throws Exception
{
assertNotNull("profiler service is null", profiler);
System.out.println("START: running test user role fallback...");
@@ -202,8 +234,7 @@
System.out.println("COMPLETED: running test user role fallback.");
}
- public void testUserRoleComboFallback()
- throws Exception
+ public void testUserRoleComboFallback() throws Exception
{
assertNotNull("profiler service is null", profiler);
System.out.println("START: running test user rolecombo fallback...");
@@ -233,7 +264,7 @@
System.out.println("COMPLETED: running test user role fallback.");
}
- protected Subject createSubject()
+ private Subject createSubject()
{
Set principals = new PrincipalsSet();
Set publicCredentials = new HashSet();
@@ -248,7 +279,7 @@
return subject;
}
- protected Subject createSubject2()
+ private Subject createSubject2()
{
Set principals = new PrincipalsSet();
Set publicCredentials = new HashSet();
@@ -262,11 +293,6 @@
return subject;
}
- /**
- * Tests
- *
- * @throws Exception
- */
public void testRules() throws Exception
{
assertNotNull("profiler service is null", profiler);
@@ -275,7 +301,7 @@
ProfilingRule rule = profiler.getDefaultRule();
assertNotNull("Default profiling rule is null", rule);
assertTrue("default rule unexpected, = " + rule.getId(), rule.getId().equals(DEFAULT_RULE));
- assertTrue("default rule class not mapped", rule instanceof StandardProfilingRule);
+ assertTrue("default rule class not mapped", rule.getClass() == getStandardProfilingRuleClass());
// Test anonymous principal-rule
ProfilingRule anonRule = profiler.getRuleForPrincipal(new UserImpl("anon"),
@@ -292,13 +318,13 @@
rule = (ProfilingRule) rules.next();
if (rule.getId().equals(DEFAULT_RULE))
{
- assertTrue("standard rule class not mapped", rule instanceof StandardProfilingRule);
+ assertTrue("standard rule class not mapped", rule.getClass() == getStandardProfilingRuleClass());
checkStandardCriteria(rule);
standardCount++;
}
else if (rule.getId().equals(FALLBACK_RULE))
{
- assertTrue("role fallback rule class not mapped", rule instanceof RoleFallbackProfilingRule);
+ assertTrue("role fallback rule class not mapped", rule.getClass() == getRoleFallbackProfilingRuleClass());
checkFallbackCriteria(rule);
fallbackCount++;
}
@@ -358,8 +384,6 @@
count++;
}
}
-
-
private void checkFallbackCriteria(ProfilingRule rule)
{
@@ -486,7 +510,6 @@
count++;
}
assertTrue("fallback count = 0, " + count, count == 0);
-
}
public void testPage() throws Exception
@@ -533,15 +556,15 @@
{
System.out.println("Maintenance tests commencing....");
assertNotNull("profiler service is null", profiler);
- ProfilingRule rule = new StandardProfilingRule(resolvers);
- rule.setClassname("org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule");
+ ProfilingRule rule = profiler.createProfilingRule(true);
+ rule.setResolvers(resolvers);
rule.setId("testmo");
rule.setTitle("The Grand Title");
profiler.storeProfilingRule(rule);
+
ProfilingRule rule2 = profiler.getRule("testmo");
assertNotNull("rule couldnt be added", rule2);
assertTrue("rule id bad", rule.getId().equals(rule2.getId()));
-
rule2.setTitle("The New Title");
profiler.storeProfilingRule(rule2);
@@ -549,31 +572,17 @@
assertNotNull("rule couldnt be retrieved", rule3);
assertTrue("rule title is bad", rule3.getTitle().equals(rule2.getTitle()));
- profiler.deleteProfilingRule(rule);
+ profiler.deleteProfilingRule(rule3);
ProfilingRule rule4 = profiler.getRule("testmo");
assertNull("rule couldnt be deleted", rule4);
System.out.println("Maintenance tests completed.");
}
- protected String[] getConfigurations()
- {
- return new String[] { "profiler.xml", "transaction.xml", "serializer.xml", "security-providers.xml", "cache-test.xml", "capabilities.xml", "registry.xml", "search.xml", "jetspeed-spring.xml",
- "security-managers.xml", "security-spi.xml", "security-spi-atn.xml", "security-atz.xml", "static-bean-references.xml" };
- }
-
- protected String getBeanDefinitionFilterCategories()
- {
- return "security,serializer,registry,search,capabilities,profiler,dbSecurity,transaction,cache,noRequestContext,jdbcDS";
- }
-
- protected RuleCriterion addRuleCriterion(ProfilingRule rule,
- String criterionName, String criterionType, String criterionValue,int fallbackOrder, int fallbackType)
- throws Exception
+ protected RuleCriterion addRuleCriterion(ProfilingRule rule, String criterionName, String criterionType, String criterionValue,int fallbackOrder, int fallbackType) throws Exception
{
assertTrue("ProfilingRule is not null", (rule != null));
-
RuleCriterion c = profiler.createRuleCriterion();
assertTrue("RuleCriterion is not null", (c != null));
c.setFallbackOrder(fallbackOrder);
@@ -581,13 +590,10 @@
c.setName(criterionName);
c.setType(criterionType);
c.setValue(criterionValue);
- c.setRuleId(rule.getId());
rule.getRuleCriteria().add(c);
return c;
}
-
-
private void createStandardCriteria(ProfilingRule rule) throws Exception
{
RuleCriterion criterion;
@@ -635,9 +641,6 @@
}
}
-
-
-
private void createFallbackCriteria(ProfilingRule rule) throws Exception
{
RuleCriterion criterion;
@@ -683,11 +686,6 @@
}
}
- /**
- * Tests
- *
- * @throws Exception
- */
public void testNewRules() throws Exception
{
assertNotNull("profiler service is null", profiler);
@@ -700,7 +698,7 @@
assertNotNull("rule is null ", rule);
rule.setId(ruleId1);
rule.setTitle("Test Rule 1");
- this.createStandardCriteria(rule);
+ createStandardCriteria(rule);
profiler.storeProfilingRule(rule);
//Check
@@ -713,7 +711,7 @@
rule.setId(ruleId2);
rule.setTitle("Test Rule 2");
- this.createFallbackCriteria(rule);
+ createFallbackCriteria(rule);
profiler.storeProfilingRule(rule);
//Check
@@ -730,13 +728,13 @@
rule = (ProfilingRule) rules.next();
if (rule.getId().equals(ruleId1))
{
- assertTrue("standard rule class not mapped", rule instanceof StandardProfilingRule);
+ assertTrue("standard rule class not mapped", rule.getClass() == getStandardProfilingRuleClass());
checkStandardCriteria(rule);
standardCount++;
}
else if (rule.getId().equals(ruleId2))
{
- assertTrue("role fallback rule class not mapped", rule instanceof RoleFallbackProfilingRule);
+ assertTrue("role fallback rule class not mapped", rule.getClass() == getRoleFallbackProfilingRuleClass());
checkFallbackCriteria(rule);
fallbackCount++;
}
@@ -750,4 +748,14 @@
assertTrue("didnt find expected number of standard rules, expected = " + EXPECTED_STANDARD, standardCount == 1);
assertTrue("didnt find expected number of fallback rules, expected = " + EXPECTED_FALLBACK, fallbackCount == 1);
}
+
+ /**
+ * Start the tests.
+ *
+ * @param args the arguments. Not used
+ */
+ public static void main(String args[])
+ {
+ junit.awtui.TestRunner.main(new String[]{TestProfiler.class.getName()});
+ }
}
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jndi.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jndi.properties?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jndi.properties (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jndi.properties Mon Jan 19 12:39:38 2009
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# ------------------------------------------------------------------------
+#
+# JNDI Naming Configuration
+#
+# $Id: $
+#
+# ------------------------------------------------------------------------
+
+java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory
+java.naming.factory.url.pkgs=org.apache.naming
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jpa-profiler.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jpa-profiler.xml?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jpa-profiler.xml (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/jpa-profiler.xml Mon Jan 19 12:39:38 2009
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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 xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/tx
+ http://www.springframework.org/schema/tx/spring-tx.xsd">
+
+ <!-- Jetspeed XA DataSource -->
+ <bean id="JetspeedXADS" class="org.springframework.jndi.JndiObjectFactoryBean">
+ <property name="resourceRef" value="false"/>
+ <property name="jndiName" value="java:comp/env/jdbc/jetspeed-xa"/>
+ </bean>
+
+ <!-- JPA Configuration -->
+ <bean id="persistenceUnitManager" class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
+ <property name="dataSources">
+ <map>
+ <entry key="jetspeed-xa" value-ref="JetspeedXADS"/>
+ <entry key="jetspeed" value-ref="JetspeedDS"/>
+ </map>
+ </property>
+ <property name="defaultDataSource" ref="JetspeedDS"/>
+ <property name="persistenceXmlLocations">
+ <list>
+ <value>classpath*:META-INF/persistence.xml</value>
+ </list>
+ </property>
+ </bean>
+ <bean id="abstractEntityManagerFactory" abstract="true" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="persistenceUnitManager" ref="persistenceUnitManager"/>
+ </bean>
+
+ <!-- Spring/Atomikos/JTA Transaction Manager -->
+ <bean id="atomikosUserTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp" init-method="init" destroy-method="shutdownForce">
+ <constructor-arg>
+ <props>
+ <!-- standard atomikos standalone configuration -->
+ <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
+ <!-- server/process name overrides for log file names -->
+ <prop key="com.atomikos.icatch.tm_unique_name">${com.atomikos.icatch.tm_unique_name}</prop>
+ <prop key="com.atomikos.icatch.log_base_dir">${com.atomikos.icatch.log_base_dir}</prop>
+ <prop key="com.atomikos.icatch.log_base_name">${com.atomikos.icatch.log_base_name}</prop>
+ <prop key="com.atomikos.icatch.output_dir">${com.atomikos.icatch.output_dir}</prop>
+ <prop key="com.atomikos.icatch.console_file_name">${com.atomikos.icatch.console_file_name}</prop>
+ </props>
+ </constructor-arg>
+ </bean>
+ <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close" depends-on="atomikosUserTransactionService">
+ <property name="forceShutdown" value="true"/>
+ </bean>
+ <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
+ <property name="transactionManager" ref="atomikosTransactionManager"/>
+ <property name="userTransactionName" value="java:comp/UserTransaction"/>
+ </bean>
+ <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
+
+ <!-- Spring Transaction Annotations -->
+ <tx:annotation-driven transaction-manager="jtaTransactionManager"/>
+
+ <!-- JPA/OpenJPA Profiler Components -->
+ <bean id="standardResolver" class="org.apache.jetspeed.profiler.rules.impl.StandardResolver"/>
+ <bean id="sessionResolver" class="org.apache.jetspeed.profiler.rules.impl.SessionResolver"/>
+ <bean id="requestSessionResolver" class="org.apache.jetspeed.profiler.rules.impl.RequestSessionResolver"/>
+ <bean id="pathResolver" class="org.apache.jetspeed.profiler.rules.impl.PathResolver"/>
+ <bean id="pathSessionResolver" class="org.apache.jetspeed.profiler.rules.impl.PathSessionResolver"/>
+ <bean id="hardCodedResolver" class="org.apache.jetspeed.profiler.rules.impl.HardCodedResolver"/>
+ <bean id="userCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.UserCriterionResolver"/>
+ <bean id="roleCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.RoleCriterionResolver"/>
+ <bean id="principalCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.PrincipalCriterionResolver"/>
+ <bean id="roleComboCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.RoleComboCriterionResolver"/>
+ <bean id="groupCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.GroupCriterionResolver"/>
+ <bean id="mediatypeCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.MediatypeCriterionResolver"/>
+ <bean id="languageCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.LanguageCriterionResolver"/>
+ <bean id="countryCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.CountryCriterionResolver"/>
+ <bean id="groupRoleUserCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.GroupRoleUserCriterionResolver"/>
+ <bean id="userAttributeResolver" class="org.apache.jetspeed.profiler.rules.impl.UserAttributeResolver"/>
+ <bean id="navigationCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.NavigationCriterionResolver"/>
+ <bean id="userAgentCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.UserAgentCriterionResolver"/>
+ <bean id="ipCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.IPCriterionResolver"/>
+ <bean id="hostnameCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.HostnameCriterionResolver">
+ <!-- use the dot prefix, for ex: "accounting.xyz.com" returns "accounting" -->
+ <constructor-arg type="boolean" index="0"><value>false</value></constructor-arg>
+ </bean>
+ <bean id="domainCriterionResolver" class="org.apache.jetspeed.profiler.rules.impl.DomainCriterionResolver"/>
+ <bean id="profileResolvers" name="ProfileResolvers" class="org.apache.jetspeed.profiler.rules.impl.ProfileResolversImpl">
+ <constructor-arg index="0">
+ <map>
+ <entry key="request"><ref bean="standardResolver"/></entry>
+ <entry key="session"><ref bean="sessionResolver"/></entry>
+ <entry key="request.session"><ref bean="requestSessionResolver"/></entry>
+ <entry key="path"><ref bean="pathResolver"/></entry>
+ <entry key="path.session"><ref bean="pathSessionResolver"/></entry>
+ <entry key="hard.coded"><ref bean="hardCodedResolver"/></entry>
+ <entry key="user"><ref bean="userCriterionResolver"/></entry>
+ <entry key="role"><ref bean="roleCriterionResolver"/></entry>
+ <entry key="rolecombo"><ref bean="roleComboCriterionResolver"/></entry>
+ <entry key="group"><ref bean="groupCriterionResolver"/></entry>
+ <entry key="mediatype"><ref bean="mediatypeCriterionResolver"/></entry>
+ <entry key="language"><ref bean="languageCriterionResolver"/></entry>
+ <entry key="country"><ref bean="countryCriterionResolver"/></entry>
+ <entry key="group.role.user"><ref bean="groupRoleUserCriterionResolver"/></entry>
+ <entry key="user.attribute"><ref bean="userAttributeResolver"/></entry>
+ <entry key="navigation"><ref bean="navigationCriterionResolver"/></entry>
+ <entry key="user.agent"><ref bean="userAgentCriterionResolver"/></entry>
+ <entry key="ip"><ref bean="ipCriterionResolver"/></entry>
+ <entry key="hostname"><ref bean="hostnameCriterionResolver"/></entry>
+ <entry key="domain"><ref bean="domainCriterionResolver"/></entry>
+ </map>
+ </constructor-arg>
+ </bean>
+ <bean id="profileLocator" class="org.apache.jetspeed.profiler.impl.JetspeedProfileLocator" scope="prototype"/>
+ <bean id="standardProfilingRule" class="org.apache.jetspeed.profiler.rules.jpa.StandardProfilingRule" scope="prototype"/>
+ <bean id="roleFallbackProfilingRule" class="org.apache.jetspeed.profiler.rules.jpa.RoleFallbackProfilingRule" scope="prototype"/>
+ <bean id="principalRule" class="org.apache.jetspeed.profiler.rules.jpa.PrincipalRuleImpl" scope="prototype"/>
+ <bean id="ruleCriterion" class="org.apache.jetspeed.profiler.rules.jpa.RuleCriterionImpl" scope="prototype"/>
+ <bean id="profiler" name="profilerImpl,org.apache.jetspeed.profiler.Profiler" class="org.apache.jetspeed.profiler.jpa.JetspeedProfilerImpl">
+ <constructor-arg index="0"><value>j2</value></constructor-arg>
+ <constructor-arg index="1"><ref bean="profileResolvers"/></constructor-arg>
+ <constructor-arg index="2">
+ <map>
+ <entry key="locator"><value>profileLocator</value></entry>
+ <entry key="principal"><value>principalRule</value></entry>
+ <entry key="standard"><value>standardProfilingRule</value></entry>
+ <entry key="fallback"><value>roleFallbackProfilingRule</value></entry>
+ </map>
+ </constructor-arg>
+ <constructor-arg index="3"><value>ruleCriterion</value></constructor-arg>
+ </bean>
+
+ <!-- JPA Profiler Manager Context -->
+ <bean id="profilerManagerContext" class="org.apache.jetspeed.profiler.jpa.ProfilerManagerContext" scope="prototype" init-method="initialize" destroy-method="terminate">
+ <property name="profilerManager" ref="profiler"/>
+ </bean>
+
+</beans>
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/log4j.properties?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/log4j.properties (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/log4j.properties Mon Jan 19 12:39:38 2009
@@ -0,0 +1,78 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+# ------------------------------------------------------------------------
+#
+# Logging Configuration
+#
+# $Id: log4j.properties 731466 2009-01-05 06:04:13Z rwatler $
+#
+# ------------------------------------------------------------------------
+
+log4j.rootCategory = ERROR, errorlogging
+
+#log4j.category.openjpa.Tool = INFO, infologging
+#log4j.category.openjpa.Runtime = INFO, infologging
+#log4j.category.openjpa.Remote = WARN, infologging
+#log4j.category.openjpa.DataCache = WARN, infologging
+#log4j.category.openjpa.MetaData = WARN, infologging
+#log4j.category.openjpa.Enhance = WARN, infologging
+#log4j.category.openjpa.Query = WARN, infologging
+#log4j.category.openjpa.jdbc.SQL = WARN, infologging
+#log4j.category.openjpa.jdbc.JDBC = WARN, infologging
+#log4j.category.openjpa.jdbc.Schema = WARN, infologging
+
+log4j.category.org.springframework = DEBUG, infologging
+log4j.additivity.org.springframework = false
+
+log4j.category.openjpa.Tool = TRACE, infologging
+log4j.additivity.openjpa.Tool = false
+log4j.category.openjpa.Runtime = TRACE, infologging
+log4j.additivity.openjpa.Runtime = false
+log4j.category.openjpa.Remote = TRACE, infologging
+log4j.additivity.openjpa.Remote = false
+log4j.category.openjpa.DataCache = TRACE, infologging
+log4j.additivity.openjpa.DataCache = false
+log4j.category.openjpa.MetaData = TRACE, infologging
+log4j.additivity.openjpa.MetaData = false
+log4j.category.openjpa.Enhance = TRACE, infologging
+log4j.additivity.openjpa.Enhance = false
+log4j.category.openjpa.Query = TRACE, infologging
+log4j.additivity.openjpa.Query = false
+log4j.category.openjpa.jdbc.SQL = TRACE, infologging
+log4j.additivity.openjpa.jdbc.SQL = false
+#log4j.category.openjpa.jdbc.JDBC = TRACE, infologging
+log4j.category.openjpa.jdbc.JDBC = DEBUG, infologging
+log4j.additivity.openjpa.jdbc.JDBC = false
+log4j.category.openjpa.jdbc.Schema = TRACE, infologging
+log4j.additivity.openjpa.jdbc.Schema = false
+
+log4j.category.org.apache.jetspeed = DEBUG, infologging
+log4j.additivity.org.apache.jetspeed = false
+
+log4j.category.atomikos = DEBUG, infologging
+log4j.additivity.atomikos = false
+
+log4j.appender.errorlogging = org.apache.log4j.FileAppender
+log4j.appender.errorlogging.file = ${basedir}/target/surefire-reports/tests-error.log
+log4j.appender.errorlogging.layout = org.apache.log4j.PatternLayout
+log4j.appender.errorlogging.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.errorlogging.append = false
+
+log4j.appender.infologging = org.apache.log4j.FileAppender
+log4j.appender.infologging.file = ${basedir}/target/surefire-reports/tests-info.log
+log4j.appender.infologging.layout = org.apache.log4j.PatternLayout
+log4j.appender.infologging.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.infologging.append = false
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/openjpa-profiler.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/openjpa-profiler.xml?rev=735797&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/openjpa-profiler.xml (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-profiler/src/test/resources/openjpa-profiler.xml Mon Jan 19 12:39:38 2009
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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 xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/tx
+ http://www.springframework.org/schema/tx/spring-tx.xsd">
+
+ <import resource="jpa-profiler.xml"/>
+
+ <!-- OpenJPA/Atomikos Configuration -->
+ <bean id="jpaProfilerProperties" class="org.apache.jetspeed.components.rdbms.jpa.OpenJPAConfigurationProperties">
+ <property name="jpaProperties">
+ <props>
+ <prop key="openjpa.ConnectionFactoryMode">managed</prop>
+ <prop key="openjpa.TransactionMode">managed</prop>
+ <prop key="openjpa.ManagedRuntime">invocation(TransactionManagerMethod=com.atomikos.icatch.jta.TransactionManagerImp.getTransactionManager)</prop>
+ </props>
+ </property>
+ </bean>
+ <bean id="profilerEntityManagerFactory" parent="abstractEntityManagerFactory">
+ <property name="persistenceUnitName" value="jetspeed-profiler"/>
+ <property name="jpaProperties" ref="jpaProfilerProperties"/>
+ <property name="jpaDialect">
+ <bean class="org.springframework.orm.jpa.vendor.OpenJpaDialect"/>
+ </property>
+ </bean>
+
+</beans>
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/jndi/NamingJavaJNDIComponent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/jndi/NamingJavaJNDIComponent.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/jndi/NamingJavaJNDIComponent.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-rdbms/src/main/java/org/apache/jetspeed/components/jndi/NamingJavaJNDIComponent.java Mon Jan 19 12:39:38 2009
@@ -20,6 +20,8 @@
import javax.naming.Context;
import javax.naming.InitialContext;
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import org.apache.naming.ContextBindings;
@@ -64,8 +66,20 @@
{
try
{
- rootContext.createSubcontext("java:comp").createSubcontext("env").createSubcontext("jdbc");
- rootContext.createSubcontext("java:jdbc");
+ try
+ {
+ rootContext.createSubcontext("java:comp").createSubcontext("env").createSubcontext("jdbc");
+ }
+ catch (NameAlreadyBoundException nabe)
+ {
+ }
+ try
+ {
+ rootContext.createSubcontext("java:jdbc");
+ }
+ catch (NameAlreadyBoundException nabe)
+ {
+ }
}
catch (NamingException ne)
{
@@ -98,7 +112,15 @@
*/
public void bindObject(String bindToName, Object obj) throws NamingException
{
- rootContext.bind("java:"+bindToName, obj);
+ bindToName = "java:"+bindToName;
+ try
+ {
+ rootContext.unbind(bindToName);
+ }
+ catch (NameNotFoundException nnfe)
+ {
+ }
+ rootContext.bind(bindToName, obj);
}
/* (non-Javadoc)
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManager.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManager.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManager.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManager.java Mon Jan 19 12:39:38 2009
@@ -50,7 +50,7 @@
public Object getContext();
/**
- * Unregister page manager context with current thread.
+ * Unregister registry manager context with current thread.
*
* @param context registry manager context.
*/
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerImpl.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/jpa/RegistryManagerImpl.java Mon Jan 19 12:39:38 2009
@@ -37,7 +37,7 @@
*/
public RegistryManagerImpl()
{
- contexts = new ThreadLocal();
+ this.contexts = new ThreadLocal();
}
// Lifecycle
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateImpl.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/CustomWindowStateImpl.java Mon Jan 19 12:39:38 2009
@@ -16,7 +16,6 @@
*/
package org.apache.jetspeed.om.portlet.jpa;
-import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamImpl.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/InitParamImpl.java Mon Jan 19 12:39:38 2009
@@ -18,7 +18,6 @@
package org.apache.jetspeed.om.portlet.jpa;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDefinitionImpl.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDefinitionImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletApplicationDefinitionImpl.java Mon Jan 19 12:39:38 2009
@@ -18,7 +18,6 @@
package org.apache.jetspeed.om.portlet.jpa;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionImpl.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/PortletDefinitionImpl.java Mon Jan 19 12:39:38 2009
@@ -17,7 +17,6 @@
package org.apache.jetspeed.om.portlet.jpa;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleImpl.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleImpl.java Mon Jan 19 12:39:38 2009
@@ -17,7 +17,6 @@
package org.apache.jetspeed.om.portlet.jpa;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefImpl.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/SecurityRoleRefImpl.java Mon Jan 19 12:39:38 2009
@@ -17,7 +17,6 @@
package org.apache.jetspeed.om.portlet.jpa;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeImpl.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeImpl.java Mon Jan 19 12:39:38 2009
@@ -16,7 +16,6 @@
*/
package org.apache.jetspeed.om.portlet.jpa;
-import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeRefImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeRefImpl.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeRefImpl.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/jpa/UserAttributeRefImpl.java Mon Jan 19 12:39:38 2009
@@ -17,7 +17,6 @@
package org.apache.jetspeed.om.portlet.jpa;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/ProfilingRule.java Mon Jan 19 12:39:38 2009
@@ -127,23 +127,6 @@
*/
void setTitle(String title);
- /**
- * Get the implementing classname of this rule from the database.
- * The class must exist in the hiearchy and in fact refers to itself when instantiated.
- *
- * @return The classname of this instance.
- */
- String getClassname();
-
- /**
- * Sets the implementing classname of this rule from the database.
- * The class must exist in the hiearchy and in fact refers to itself when instantiated.
- *
- * @param classname The classname of this instance.
- */
- void setClassname(String classname);
-
ProfileResolvers getResolvers();
void setResolvers(ProfileResolvers resolvers);
-
}
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/RuleCriterion.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/RuleCriterion.java?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/RuleCriterion.java (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-api/src/main/java/org/apache/jetspeed/profiler/rules/RuleCriterion.java Mon Jan 19 12:39:38 2009
@@ -131,19 +131,4 @@
* @param The value of the request parameter, attribute or property.
*/
void setValue(String value);
-
- /**
- * Gets the unique rule identifier for the associated owner rule
- *
- * @return The rule's unique identifier
- */
- String getRuleId();
-
- /**
- * Sets the unique rule identifier for the associated owner rule
- *
- * @param id The rule's unique identifier
- */
- void setRuleId(String ruleId);
-
}
Modified: portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-portal-resources/src/main/ddl-schema/phase2-schema.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-portal-resources/src/main/ddl-schema/phase2-schema.xml?rev=735797&r1=735796&r2=735797&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-portal-resources/src/main/ddl-schema/phase2-schema.xml (original)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/jetspeed-portal-resources/src/main/ddl-schema/phase2-schema.xml Mon Jan 19 12:39:38 2009
@@ -627,11 +627,11 @@
size="80" type="VARCHAR"/>
<column name="CLASS_NAME" required="true" size="100" type="VARCHAR"/>
<column name="TITLE" size="100" type="VARCHAR"/>
+ <column name="JPA_VERSION" type="INTEGER"/>
</table>
<table name="RULE_CRITERION">
- <column name="CRITERION_ID" primaryKey="true" required="true"
- size="80" type="VARCHAR"/>
+ <column name="CRITERION_ID" primaryKey="true" required="true" type="INTEGER"/>
<column name="RULE_ID" required="true" size="80" type="VARCHAR"/>
<column name="FALLBACK_ORDER" required="true" type="INTEGER"/>
<column name="REQUEST_TYPE" required="true" size="40" type="VARCHAR"/>
@@ -645,12 +645,14 @@
<foreign-key foreignTable="PROFILING_RULE" name="FK_RULE_CRITERION_1" onDelete="cascade">
<reference foreign="RULE_ID" local="RULE_ID"/>
</foreign-key>
+ <column name="JPA_VERSION" type="INTEGER"/>
</table>
<table name="PRINCIPAL_RULE_ASSOC">
<column name="PRINCIPAL_NAME" primaryKey="true" required="true" size="80" type="VARCHAR"/>
<column name="LOCATOR_NAME" primaryKey="true" required="true" size="80" type="VARCHAR"/>
<column name="RULE_ID" required="true" size="80" type="VARCHAR"/>
+ <column name="JPA_VERSION" type="INTEGER"/>
</table>
<table name="PROFILE_PAGE_ASSOC">
@@ -660,6 +662,7 @@
<unique-column name="LOCATOR_HASH" />
<unique-column name="PAGE_ID" />
</unique>
+ <column name="JPA_VERSION" type="INTEGER"/>
</table>
<table name="CLUBS">
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org