portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r510754 - in /portals/jetspeed-2/trunk: components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/ src/webapp/WEB-INF/assembly/
Date Fri, 23 Feb 2007 01:42:23 GMT
Author: taylor
Date: Thu Feb 22 17:42:22 2007
New Revision: 510754

URL: http://svn.apache.org/viewvc?view=rev&rev=510754
Log:
contribution from Frank Stalherm
added a few rules for hostname and domain name to profiling rules
had this one sitting around and promised to get it in before release

Added:
    portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/DomainCriterionResolver.java
    portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java
Modified:
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/profiler.xml

Added: portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/DomainCriterionResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/DomainCriterionResolver.java?view=auto&rev=510754
==============================================================================
--- portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/DomainCriterionResolver.java
(added)
+++ portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/DomainCriterionResolver.java
Thu Feb 22 17:42:22 2007
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2000-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.profiler.rules.impl;
+
+import org.apache.jetspeed.profiler.rules.RuleCriterion;
+import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Hostname Resolver
+ * 
+ * @author <a href="mailto:stalherm@goodgulf.net">Frank Stalherm</a>
+ * @version $Id:$
+ */
+public class DomainCriterionResolver extends StandardResolver implements
+        RuleCriterionResolver
+{
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.profiler.rules.impl.StandardResolver#isControl(org.apache.jetspeed.profiler.rules.RuleCriterion)
+     */
+    public boolean isControl(RuleCriterion criterion)
+    {
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.profiler.rules.impl.StandardResolver#isNavigation(org.apache.jetspeed.profiler.rules.RuleCriterion)
+     */
+    public boolean isNavigation(RuleCriterion criterion)
+    {
+        return true;
+    }
+
+    public String resolve(RequestContext context, RuleCriterion criterion)
+    {
+        return getDomain(context.getRequest().getServerName());
+    }
+
+    /**
+     * extracts the domain from the servername from RequestContext
+     * 
+     * @param servername
+     *            server name from request
+     * @return domain extracted from server name
+     */
+    public static String getDomain(String servername)
+    {
+        String domain = null;
+
+        if (servername != null)
+        {
+            int idx = servername.indexOf(".");
+            if (idx != -1)
+            {
+                domain = servername.substring(idx + 1, servername.length());
+            } else
+            {
+                // maybe there is no domain
+                // testing for IPv6 IP Address
+                idx = servername.indexOf(":");
+                if (idx != -1)
+                {
+                    // TODO resolving IP Address?
+                    // no domain is available
+                    domain = "";
+                } else
+                {
+                    // no domain is available
+                    domain = "";
+                }
+            }
+        }
+        return domain;
+    }
+
+}

Added: portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java?view=auto&rev=510754
==============================================================================
--- portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java
(added)
+++ portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/HostnameCriterionResolver.java
Thu Feb 22 17:42:22 2007
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2000-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.profiler.rules.impl;
+
+import org.apache.jetspeed.profiler.rules.RuleCriterion;
+import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Hostname Resolver
+ * 
+ * @author <a href="mailto:stalherm@goodgulf.net">Frank Stalherm</a>
+ * @version $Id:$
+ */
+public class HostnameCriterionResolver extends StandardResolver implements
+        RuleCriterionResolver
+{
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.profiler.rules.impl.StandardResolver#isControl(org.apache.jetspeed.profiler.rules.RuleCriterion)
+     */
+    public boolean isControl(RuleCriterion criterion)
+    {
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.jetspeed.profiler.rules.impl.StandardResolver#isNavigation(org.apache.jetspeed.profiler.rules.RuleCriterion)
+     */
+    public boolean isNavigation(RuleCriterion criterion)
+    {
+        return true;
+    }
+
+    public String resolve(RequestContext context, RuleCriterion criterion)
+    {
+        return getHostname(context.getRequest().getServerName());
+    }
+
+    /**
+     * extracts the hostname from the servername from RequestContext
+     * 
+     * @param servername
+     *            server name from request
+     * @return hostname extracted from server name
+     */
+    public String getHostname(String servername)
+    {
+        String hostname = null;
+
+        if (servername != null)
+        {
+            int idx = servername.indexOf(".");
+            if (idx != -1)
+            {
+                hostname = servername.substring(idx, servername.length());
+            } else
+            {
+                // maybe we already have the hostname
+                // testing for IPv6 IP Address
+                idx = servername.indexOf(":");
+                if (idx != -1)
+                {
+                    // TODO resolving IP Address?
+                    // for now we take this as the host name
+                    hostname = servername;
+                } else
+                {
+                    // looks like hostname==servername
+                    hostname = servername;
+                }
+            }
+        }
+        return hostname;
+    }
+
+}

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/profiler.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/profiler.xml?view=diff&rev=510754&r1=510753&r2=510754
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/profiler.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/profiler.xml Thu Feb 22 17:42:22
2007
@@ -126,6 +126,12 @@
           <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>
@@ -148,6 +154,8 @@
     <bean id='NavigationCriterionResolver' class='org.apache.jetspeed.profiler.rules.impl.NavigationCriterionResolver'></bean>
     <bean id='UserAgentCriterionResolver' class='org.apache.jetspeed.profiler.rules.impl.UserAgentCriterionResolver'></bean>
     <bean id='IPCriterionResolver' class='org.apache.jetspeed.profiler.rules.impl.IPCriterionResolver'></bean>
+    <bean id='HostnameCriterionResolver' class='org.apache.jetspeed.profiler.rules.impl.HostnameCriterionResolver'></bean>
   
+    <bean id='DomainCriterionResolver' class='org.apache.jetspeed.profiler.rules.impl.DomainCriterionResolver'></bean>
     
 
 	<!-- Profiling Rules -->
 



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message