Return-Path: Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: (qmail 66760 invoked from network); 7 May 2010 15:14:15 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 May 2010 15:14:15 -0000 Received: (qmail 72055 invoked by uid 500); 7 May 2010 15:14:15 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 72008 invoked by uid 500); 7 May 2010 15:14:14 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 72001 invoked by uid 99); 7 May 2010 15:14:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 May 2010 15:14:14 +0000 X-ASF-Spam-Status: No, hits=-1150.2 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 May 2010 15:14:13 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E78BB23889EB; Fri, 7 May 2010 15:13:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r942112 - in /qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server: plugins/ virtualhost/ virtualhost/plugin/ Date: Fri, 07 May 2010 15:13:23 -0000 To: commits@qpid.apache.org From: ritchiem@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100507151323.E78BB23889EB@eris.apache.org> Author: ritchiem Date: Fri May 7 15:13:23 2010 New Revision: 942112 URL: http://svn.apache.org/viewvc?rev=942112&view=rev Log: QPID-2584 : Updated VirtualHost to load VirtualHost Plugins and not hard code SCD Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginFactory.java qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPlugin.java qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPluginFactory.java Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginFactory.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginFactory.java?rev=942112&view=auto ============================================================================== --- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginFactory.java (added) +++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/plugins/PluginFactory.java Fri May 7 15:13:23 2010 @@ -0,0 +1,26 @@ +/* + * + * 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.qpid.server.plugins; + +public interface PluginFactory +{ + public String getPluginName(); +} Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java?rev=942112&r1=942111&r2=942112&view=diff ============================================================================== --- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java (original) +++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHostImpl.java Fri May 7 15:13:23 2010 @@ -28,6 +28,8 @@ import org.apache.qpid.AMQException; import org.apache.qpid.framing.AMQShortString; import org.apache.qpid.framing.FieldTable; import org.apache.qpid.server.AMQBrokerManagerMBean; +import org.apache.qpid.server.virtualhost.plugin.VirtualHostPluginFactory; +import org.apache.qpid.server.virtualhost.plugin.VirtualHostPlugin; import org.apache.qpid.server.binding.BindingFactory; import org.apache.qpid.server.configuration.BrokerConfig; import org.apache.qpid.server.configuration.ConfigStore; @@ -72,8 +74,10 @@ import java.util.List; import java.util.Timer; import java.util.TimerTask; import java.util.UUID; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; - +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; public class VirtualHostImpl implements Accessable, VirtualHost { @@ -321,6 +325,54 @@ public class VirtualHostImpl implements _connectionRegistry.expireClosedChannels(); } } + + Map plugins = + ApplicationRegistry.getInstance(). + getPluginManager().getVirtualHostPlugins(); + + if (plugins != null) + { + ScheduledThreadPoolExecutor vhostTasks = new ScheduledThreadPoolExecutor(plugins.size()); + + for (String pluginName : plugins.keySet()) + { + try + { + VirtualHostPlugin plugin = plugins.get(pluginName).newInstance(this); + + TimeUnit units = TimeUnit.MILLISECONDS; + + if (plugin.getTimeUnit() != null) + { + try + { + units = TimeUnit.valueOf(plugin.getTimeUnit()); + } + catch (IllegalArgumentException iae) + { + _logger.warn("Plugin:" + pluginName + + " provided an illegal TimeUnit value:" + + plugin.getTimeUnit()); + // Warn and use default of millseconds + // Should not occur in a well behaved plugin + } + } + + vhostTasks.scheduleAtFixedRate(plugin, plugin.getDelay() / 2, + plugin.getDelay(), units); + + _logger.info("Loaded VirtualHostPlugin:" + plugin); + } + catch (IllegalArgumentException iae) + { + _logger.warn("VirtualHostPlugin:" + pluginName + " has not been configured for this virtualhost(" + getName() + ")"); + } + catch (Exception e) + { + _logger.error("Unable to load VirtualHostPlugin:" + pluginName + " due to:" + e.getMessage(), e); + } + } + } } } Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPlugin.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPlugin.java?rev=942112&view=auto ============================================================================== --- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPlugin.java (added) +++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPlugin.java Fri May 7 15:13:23 2010 @@ -0,0 +1,40 @@ +/* + * + * 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.qpid.server.virtualhost.plugin; + +public interface VirtualHostPlugin extends Runnable +{ + public void run(); + + /** + * Long value representing the delay between repeats + * + * @return + */ + public long getDelay(); + + /** + * Option to specify what the delay value represents + * @see java.util.concurrent.TimeUnit for valid value. + * @return + */ + public String getTimeUnit(); +} Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPluginFactory.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPluginFactory.java?rev=942112&view=auto ============================================================================== --- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPluginFactory.java (added) +++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/plugin/VirtualHostPluginFactory.java Fri May 7 15:13:23 2010 @@ -0,0 +1,28 @@ +/* + * + * 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.qpid.server.virtualhost.plugin; + +import org.apache.qpid.server.virtualhost.VirtualHost; + +public interface VirtualHostPluginFactory +{ + public VirtualHostPlugin newInstance(VirtualHost vhost); +} --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscribe@qpid.apache.org