You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/04/25 07:34:10 UTC
[12/51] [partial] BlazeDS Donation from Adobe Systems Inc
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/MessageDestinationControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/MessageDestinationControl.java b/modules/core/src/flex/management/runtime/messaging/MessageDestinationControl.java
new file mode 100755
index 0000000..2cefc37
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/MessageDestinationControl.java
@@ -0,0 +1,312 @@
+/*
+ * 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 flex.management.runtime.messaging;
+
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.Destination;
+
+import javax.management.ObjectName;
+
+/**
+ * The <code>MessageDestinationControl</code> class is the MBean implementation for
+ * monitoring and managing a <code>MessageDestination</code> at runtime.
+ *
+ * @author shodgson
+ */
+public class MessageDestinationControl extends DestinationControl implements
+ MessageDestinationControlMBean
+{
+ private static final String TYPE = "MessageDestination";
+ private ObjectName messageCache;
+ private ObjectName throttleManager;
+ private ObjectName subscriptionManager;
+
+ private AtomicInteger serviceMessageCount = new AtomicInteger(0);
+ private Date lastServiceMessageTimestamp;
+ private long serviceMessageStart;
+ private AtomicInteger serviceCommandCount = new AtomicInteger(0);
+ private Date lastServiceCommandTimestamp;
+ private long serviceCommandStart;
+ private AtomicInteger serviceMessageFromAdapterCount = new AtomicInteger(0);
+ private Date lastServiceMessageFromAdapterTimestamp;
+ private long serviceMessageFromAdapterStart;
+ /**
+ * Constructs a new <code>MessageDestinationControl</code> instance.
+ *
+ * @param destination The destination managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public MessageDestinationControl(Destination destination, BaseControl parent)
+ {
+ super(destination, parent);
+ serviceMessageStart = System.currentTimeMillis();
+ serviceCommandStart = serviceMessageStart;
+ serviceMessageFromAdapterStart = serviceMessageStart;
+ }
+
+ protected void onRegistrationComplete()
+ {
+ String name = this.getObjectName().getCanonicalName();
+
+ String[] pollablePerInterval = { "ServiceCommandCount", "ServiceMessageCount",
+ "ServiceMessageFromAdapterCount" };
+ String[] pollableGeneral = { "ServiceCommandFrequency", "ServiceMessageFrequency",
+ "ServiceMessageFromAdapterFrequency", "LastServiceCommandTimestamp",
+ "LastServiceMessageTimestamp", "LastServiceMessageFromAdapterTimestamp"};
+
+ getRegistrar().registerObjects(
+ new int[] {AdminConsoleTypes.DESTINATION_POLLABLE, AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL},
+ name, pollablePerInterval);
+ getRegistrar().registerObjects(AdminConsoleTypes.DESTINATION_POLLABLE, name,
+ pollableGeneral);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getType()
+ */
+ public String getType()
+ {
+ return TYPE;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageDestinationControlMBean#getMessageCache()
+ */
+ public ObjectName getMessageCache()
+ {
+ return messageCache;
+ }
+
+ /**
+ * Sets the <code>ObjectName</code> for the message cache used by the managed destination.
+ *
+ * @param value The <code>ObjectName</code> for the message cache.
+ */
+ public void setMessageCache(ObjectName value)
+ {
+ messageCache = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageDestinationControlMBean#getThrottleManager()
+ */
+ public ObjectName getThrottleManager()
+ {
+ return throttleManager;
+ }
+
+ /**
+ * Sets the <code>ObjectName</code> for the throttle manager used by the managed destination.
+ *
+ * @param value The <code>ObjectName</code> for the throttle manager.
+ */
+ public void setThrottleManager(ObjectName value)
+ {
+ throttleManager = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.MessageDestinationControlMBean#getSubscriptionManager()
+ */
+ public ObjectName getSubscriptionManager()
+ {
+ return subscriptionManager;
+ }
+
+ /**
+ * Sets the <code>ObjectName</code> for the subscription manager used by the managed destination.
+ *
+ * @param value The <code>ObjectName</code> for the subscription manager.
+ */
+ public void setSubscriptionManager(ObjectName value)
+ {
+ subscriptionManager = value;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageCount()
+ */
+ public Integer getServiceMessageCount()
+ {
+ return Integer.valueOf(serviceMessageCount.get());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceMessageCount()
+ */
+ public void resetServiceMessageCount()
+ {
+ serviceMessageStart = System.currentTimeMillis();
+ serviceMessageCount = new AtomicInteger(0);
+ lastServiceMessageTimestamp = null;
+ }
+
+ /**
+ * Increments the count of messages serviced.
+ */
+ public void incrementServiceMessageCount()
+ {
+ serviceMessageCount.incrementAndGet();
+ lastServiceMessageTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceMessageTimestamp()
+ */
+ public Date getLastServiceMessageTimestamp()
+ {
+ return lastServiceMessageTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFrequency()
+ */
+ public Double getServiceMessageFrequency()
+ {
+ if (serviceMessageCount.get() > 0)
+ {
+ double runtime = differenceInMinutes(serviceMessageStart, System.currentTimeMillis());
+ return new Double(serviceMessageCount.get()/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceCommandCount()
+ */
+ public Integer getServiceCommandCount()
+ {
+ return Integer.valueOf(serviceCommandCount.get());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceCommandCount()
+ */
+ public void resetServiceCommandCount()
+ {
+ serviceCommandStart = System.currentTimeMillis();
+ serviceCommandCount = new AtomicInteger(0);
+ lastServiceCommandTimestamp = null;
+ }
+
+ /**
+ * Increments the count of command messages serviced.
+ */
+ public void incrementServiceCommandCount()
+ {
+ serviceCommandCount.incrementAndGet();
+ lastServiceCommandTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceCommandTimestamp()
+ */
+ public Date getLastServiceCommandTimestamp()
+ {
+ return lastServiceCommandTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceCommandFrequency()
+ */
+ public Double getServiceCommandFrequency()
+ {
+ if (serviceCommandCount.get() > 0)
+ {
+ double runtime = differenceInMinutes(serviceCommandStart, System.currentTimeMillis());
+ return new Double(serviceCommandCount.get()/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFromAdapterCount()
+ */
+ public Integer getServiceMessageFromAdapterCount()
+ {
+ return Integer.valueOf(serviceMessageFromAdapterCount.get());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceMessageFromAdapterCount()
+ */
+ public void resetServiceMessageFromAdapterCount()
+ {
+ serviceMessageFromAdapterStart = System.currentTimeMillis();
+ serviceMessageFromAdapterCount = new AtomicInteger(0);
+ lastServiceMessageFromAdapterTimestamp = null;
+ }
+
+ /**
+ * Increments the count of messages from adapters processed.
+ */
+ public void incrementServiceMessageFromAdapterCount()
+ {
+ serviceMessageFromAdapterCount.incrementAndGet();
+ lastServiceMessageFromAdapterTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceMessageFromAdapterTimestamp()
+ */
+ public Date getLastServiceMessageFromAdapterTimestamp()
+ {
+ return lastServiceMessageFromAdapterTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFromAdapterFrequency()
+ */
+ public Double getServiceMessageFromAdapterFrequency()
+ {
+ if (serviceMessageFromAdapterCount.get() > 0)
+ {
+ double runtime = differenceInMinutes(serviceMessageFromAdapterStart, System.currentTimeMillis());
+ return new Double(serviceMessageFromAdapterCount.get()/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/MessageDestinationControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/MessageDestinationControlMBean.java b/modules/core/src/flex/management/runtime/messaging/MessageDestinationControlMBean.java
new file mode 100755
index 0000000..43da0a7
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/MessageDestinationControlMBean.java
@@ -0,0 +1,155 @@
+/*
+ * 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 flex.management.runtime.messaging;
+
+import java.io.IOException;
+import java.util.Date;
+
+import javax.management.ObjectName;
+
+
+/**
+ * Defines the runtime monitoring and management interface for managed
+ * <code>MessageDestination</code>s.
+ *
+ * @author shodgson
+ */
+public interface MessageDestinationControlMBean extends DestinationControlMBean
+{
+ /**
+ * Returns the <code>ObjectName</code> for the message cache used by the managed
+ * destination.
+ *
+ * @return The <code>ObjectName</code> for the message cache.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName getMessageCache() throws IOException;
+
+ /**
+ * Returns the <code>ObjectName</code> for the throttle manager used by the
+ * managed destination.
+ *
+ * @return The <code>ObjectName</code> for the throttle manager.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName getThrottleManager() throws IOException;
+
+ /**
+ * Returns the <code>ObjectName</code> for the subscription manager used
+ * by the managed destination.
+ *
+ * @return The <code>ObjectName</code> for the subscription manager.
+ * @throws IOException Throws IOException.
+ */
+ ObjectName getSubscriptionManager() throws IOException;
+
+ /**
+ * Returns the number of service message invocations.
+ *
+ * @return The number of service message invocations.
+ * @throws IOException Throws IOException.
+ */
+ Integer getServiceMessageCount() throws IOException;
+
+ /**
+ * Resets the count of service message invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetServiceMessageCount() throws IOException;
+
+ /**
+ * Returns the timestamp for the most recent service message
+ * invocation.
+ *
+ * @return The timestamp for the most recent service message invocation.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastServiceMessageTimestamp() throws IOException;
+
+ /**
+ * Returns the number of service message invocations per minute.
+ *
+ * @return The number of service message invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getServiceMessageFrequency() throws IOException;
+
+ /**
+ * Returns the number of service command invocations.
+ *
+ * @return The number of service command invocations.
+ * @throws IOException Throws IOException.
+ */
+ Integer getServiceCommandCount() throws IOException;
+
+ /**
+ * Resets the count of service command invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetServiceCommandCount() throws IOException;
+
+ /**
+ * Returns the timestamp for the most recent service command invocation.
+ *
+ * @return The timestamp for the most recent service command invocation.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastServiceCommandTimestamp() throws IOException;
+
+ /**
+ * Returns the number of service command invocations per minute.
+ *
+ * @return The number of service command invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getServiceCommandFrequency() throws IOException;
+
+ /**
+ * Returns the number of messages from an adapter that the managed service
+ * has processed.
+ *
+ * @return The number of messages from an adapter that the managed service
+ * has processed
+ * @throws IOException Throws IOException.
+ */
+ Integer getServiceMessageFromAdapterCount() throws IOException;
+
+ /**
+ * Resets the count of service message from adapter invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetServiceMessageFromAdapterCount() throws IOException;
+
+ /**
+ * Returns the timestamp of the most recent service message from adapter invocation.
+ *
+ * @return The timestamp of the most recent service message from adapter invocation.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastServiceMessageFromAdapterTimestamp() throws IOException;
+
+ /**
+ * Returns the number of service message from adapter invocations per minute.
+ *
+ * @return The number of service message from adapter invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getServiceMessageFromAdapterFrequency() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControl.java b/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControl.java
new file mode 100755
index 0000000..70fe26b
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControl.java
@@ -0,0 +1,99 @@
+/*
+ * 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 flex.management.runtime.messaging.client;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.client.FlexClientManager;
+
+/**
+ * @author majacobs
+ *
+ * @exclude
+ */
+public class FlexClientManagerControl extends BaseControl implements FlexClientManagerControlMBean
+{
+ private FlexClientManager flexClientManager;
+
+ public FlexClientManagerControl(BaseControl parent, FlexClientManager manager)
+ {
+ super(parent);
+ flexClientManager = manager;
+ }
+
+ public void onRegistrationComplete()
+ {
+ String name = getObjectName().getCanonicalName();
+ getRegistrar().registerObject(AdminConsoleTypes.GENERAL_POLLABLE, name, "FlexClientCount");
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.BaseControl#getId()
+ */
+ public String getId()
+ {
+ return flexClientManager.getId();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.BaseControl#getType()
+ */
+ public String getType()
+ {
+ return flexClientManager.getId();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientIds()
+ */
+ public String[] getClientIds()
+ {
+ return flexClientManager.getClientIds();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientLastUse(java.lang.String)
+ */
+ public Long getClientLastUse(String clientId)
+ {
+ return new Long(flexClientManager.getFlexClient(clientId).getLastUse());
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientSessionCount(java.lang.String)
+ */
+ public Integer getClientSessionCount(String clientId)
+ {
+ return new Integer(flexClientManager.getFlexClient(clientId).getSessionCount());
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getClientSubscriptionCount(java.lang.String)
+ */
+ public Integer getClientSubscriptionCount(String clientId)
+ {
+ return new Integer(flexClientManager.getFlexClient(clientId).getSubscriptionCount());
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.client.FlexClientManagerControlMBean#getFlexClientCount()
+ */
+ public Integer getFlexClientCount()
+ {
+ return new Integer(flexClientManager.getFlexClientCount());
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControlMBean.java b/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControlMBean.java
new file mode 100755
index 0000000..f56419b
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/client/FlexClientManagerControlMBean.java
@@ -0,0 +1,70 @@
+/*
+ * 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 flex.management.runtime.messaging.client;
+
+import java.io.IOException;
+
+import flex.management.BaseControlMBean;
+
+/**
+ * Defines the runtime monitoring and management interface for managed flex client managers.
+ */
+public interface FlexClientManagerControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns ids of managed clients.
+ *
+ * @return An array of client ids.
+ * @throws IOException Throws IOException.
+ */
+ String[] getClientIds() throws IOException;
+
+ /**
+ * Returns the number of subscriptions for the client with the clientId.
+ *
+ * @param clientId The client id.
+ * @return The number of subscriptions for the client with the cliendId
+ * @throws IOException Throws IOException.
+ */
+ Integer getClientSubscriptionCount(String clientId) throws IOException;
+
+ /**
+ * Returns the number of sessiosn for the client with the clientId.
+ *
+ * @param clientId The client id.
+ * @return The number of sessions for the client with the cliendId
+ * @throws IOException Throws IOException.
+ */
+ Integer getClientSessionCount(String clientId) throws IOException;
+
+ /**
+ * Returns the last use by the client with the clientId.
+ *
+ * @param clientId The client id.
+ * @return The last use by the client with the clientId
+ * @throws IOException Throws IOException.
+ */
+ Long getClientLastUse(String clientId) throws IOException;
+
+ /**
+ * Returns the number of clients.
+ *
+ * @return The number of clients.
+ * @throws IOException Throws IOException.
+ */
+ Integer getFlexClientCount() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/client/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/client/package-info.java b/modules/core/src/flex/management/runtime/messaging/client/package-info.java
new file mode 100755
index 0000000..e09baf8
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/client/package-info.java
@@ -0,0 +1,17 @@
+/*
+ * 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 flex.management.runtime.messaging.client;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControl.java
new file mode 100755
index 0000000..f127ba6
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControl.java
@@ -0,0 +1,50 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.messaging.endpoints.AMFEndpoint;
+
+/**
+ * The <code>AMFEndpointControl</code> class is the MBean implemenation
+ * for monitoring and managing an <code>AMFEndpoint</code> at runtime.
+ *
+ * @author shodgson
+ */
+public class AMFEndpointControl extends PollingEndpointControl implements
+ AMFEndpointControlMBean
+{
+ private static final String TYPE = "AMFEndpoint";
+
+ /**
+ * Constructs a <code>AMFEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>AMFEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public AMFEndpointControl(AMFEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControlMBean.java
new file mode 100755
index 0000000..6c221b8
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/AMFEndpointControlMBean.java
@@ -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 flex.management.runtime.messaging.endpoints;
+
+
+/**
+ * Defines the runtime monitoring and management interface for managed AMF endpoints.
+ *
+ * @author shodgson
+ */
+public interface AMFEndpointControlMBean extends PollingEndpointControlMBean
+{
+ // Empty for now.
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControl.java
new file mode 100755
index 0000000..2d127ce
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControl.java
@@ -0,0 +1,241 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.management.runtime.messaging.MessageBrokerControl;
+import flex.messaging.config.SecurityConstraint;
+import flex.messaging.endpoints.Endpoint;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * The <code>EndpointControl</code> class is the MBean implementation for
+ * monitoring and managing an <code>Endpoint</code> at runtime.
+ *
+ * @author shodgson
+ */
+public abstract class EndpointControl extends BaseControl implements EndpointControlMBean
+{
+ protected Endpoint endpoint;
+ private AtomicInteger serviceMessageCount = new AtomicInteger(0);
+ private Date lastServiceMessageTimestamp;
+ private long serviceMessageStart;
+ private AtomicLong bytesDeserialized = new AtomicLong(0);
+ private AtomicLong bytesSerialized = new AtomicLong(0);
+
+ /**
+ * Constructs an <code>EndpointControl</code>, assigning its managed endpoint and
+ * parent MBean.
+ *
+ * @param endpoint The <code>Endpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public EndpointControl(Endpoint endpoint, BaseControl parent)
+ {
+ super(parent);
+ this.endpoint = endpoint;
+ serviceMessageStart = System.currentTimeMillis();
+ }
+
+
+ protected void onRegistrationComplete()
+ {
+ String name = this.getObjectName().getCanonicalName();
+ String[] generalNames = { "SecurityConstraint"};
+ String[] generalPollables = { "ServiceMessageCount", "LastServiceMessageTimestamp", "ServiceMessageFrequency"};
+ String[] pollableGraphByInterval = {"BytesDeserialized", "BytesSerialized"};
+
+ getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_SCALAR,
+ name, generalNames);
+ getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_POLLABLE,
+ name, generalPollables);
+ getRegistrar().registerObjects(new int[] {AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL, AdminConsoleTypes.ENDPOINT_POLLABLE},
+ name, pollableGraphByInterval);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.BaseControlMBean#getId()
+ */
+ public String getId()
+ {
+ return endpoint.getId();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#isRunning()
+ */
+ public Boolean isRunning()
+ {
+ return Boolean.valueOf(endpoint.isStarted());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getStartTimestamp()
+ */
+ public Date getStartTimestamp()
+ {
+ return startTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getServiceMessageCount()
+ */
+ public Integer getServiceMessageCount()
+ {
+ return Integer.valueOf(serviceMessageCount.get());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#resetServiceMessageCount()
+ */
+ public void resetServiceMessageCount()
+ {
+ serviceMessageStart = System.currentTimeMillis();
+ serviceMessageCount = new AtomicInteger(0);
+ lastServiceMessageTimestamp = null;
+ }
+
+ /**
+ * Increments the count of <code>serviceMessage()</code> invocations by the endpoint.
+ */
+ public void incrementServiceMessageCount()
+ {
+ serviceMessageCount.incrementAndGet();
+ lastServiceMessageTimestamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getLastServiceMessageTimestamp()
+ */
+ public Date getLastServiceMessageTimestamp()
+ {
+ return lastServiceMessageTimestamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getServiceMessageFrequency()
+ */
+ public Double getServiceMessageFrequency()
+ {
+ if (serviceMessageCount.get() > 0)
+ {
+ double runtime = differenceInMinutes(serviceMessageStart, System.currentTimeMillis());
+ return new Double(serviceMessageCount.get()/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.management.MBeanRegistration#preDeregister()
+ */
+ public void preDeregister() throws Exception
+ {
+ MessageBrokerControl parent = (MessageBrokerControl)getParentControl();
+ parent.removeEndpoint(getObjectName());
+ }
+
+ public String getURI()
+ {
+ return endpoint.getUrl();
+ }
+
+ public String getSecurityConstraint()
+ {
+ return getSecurityConstraintOf(endpoint);
+ }
+
+ public static String getSecurityConstraintOf(Endpoint endpoint)
+ {
+ String result = "None";
+
+ SecurityConstraint constraint = endpoint.getSecurityConstraint();
+ if (constraint != null)
+ {
+ String authMethod = constraint.getMethod();
+ if (authMethod != null)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(authMethod);
+
+ List roles = constraint.getRoles();
+ if ((roles != null) && !roles.isEmpty())
+ {
+ buffer.append(':');
+ for (int i = 0; i < roles.size(); i++)
+ {
+ if (i > 0)
+ {
+ buffer.append(',');
+ }
+ buffer.append(' ');
+ buffer.append(roles.get(i));
+ }
+ }
+ result = buffer.toString();
+ }
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getBytesDeserialized()
+ */
+ public Long getBytesDeserialized(){
+ return Long.valueOf(bytesDeserialized.get());
+ }
+
+ /**
+ * Increments the count of bytes deserialized by the endpoint.
+ * @param currentBytesDeserialized the bytes is deserialized
+ */
+ public void addToBytesDeserialized(int currentBytesDeserialized) {
+ bytesDeserialized.addAndGet(currentBytesDeserialized);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.EndpointControlMBean#getBytesSerialized()
+ */
+ public Long getBytesSerialized() {
+ return Long.valueOf(bytesSerialized.get());
+ }
+
+ /**
+ * Increments the count of bytes serialized by the endpoint.
+ * @param currentBytesSerialized the bytes is serialized
+ */
+ public void addToBytesSerialized(int currentBytesSerialized) {
+ bytesSerialized.addAndGet(currentBytesSerialized);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControlMBean.java
new file mode 100755
index 0000000..d0aa61a
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/EndpointControlMBean.java
@@ -0,0 +1,113 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControlMBean;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Defines the runtime monitoring and management interface for managed endpoints.
+ *
+ * @author shodgson
+ */
+public interface EndpointControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns <code>true</code> if the <code>Endpoint</code> is running.
+ *
+ * @return <code>true</code> if the <code>Endpoint</code> is running.
+ * @throws IOException Throws IOException.
+ */
+ Boolean isRunning() throws IOException;
+
+ /**
+ * Returns the start timestamp for the <code>Endpoint</code>.
+ *
+ * @return The start timestamp for the <code>Endpoint</code>.
+ * @throws IOException Throws IOException.
+ */
+ Date getStartTimestamp() throws IOException;
+
+ /**
+ * Returns the count of messages decoded by this endpoint and routed to the broker.
+ *
+ * @return The count of messages decoded by this endpoint and routed to the broker.
+ * @throws IOException Throws IOException.
+ */
+ Integer getServiceMessageCount() throws IOException;
+
+ /**
+ * Resets the count of service message invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetServiceMessageCount() throws IOException;
+
+ /**
+ * Returns the timestamp for the most recent message decoded by this endpoint and
+ * routed to the broker.
+ *
+ * @return The timestamp for the most recent message decoded by this endpoint and
+ * routed to the broker.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastServiceMessageTimestamp() throws IOException;
+
+ /**
+ * Returns the number of service message invocations per minute.
+ *
+ * @return The number of service message invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getServiceMessageFrequency() throws IOException;
+
+ /**
+ * Returns the URI that corresponds to this endpoint.
+ *
+ * @return The URI that corresponds to this endpoint.
+ * @throws IOException Throws IOException.
+ */
+ String getURI() throws IOException;
+
+ /**
+ * Returns the security constraint that is associated with this endpoint.
+ *
+ * @return The security constraint that is associated with this endpoint.
+ * @throws IOException Throws IOException.
+ */
+ String getSecurityConstraint() throws IOException;
+
+ /**
+ * Returns the total Bytes that have been deserialized by this endpoint
+ * during its lifetime.
+ *
+ * @return total Bytes deserialized.
+ * @throws IOException Throws IOException.
+ */
+ Long getBytesDeserialized() throws IOException;
+
+ /**
+ * Returns the total Bytes that have been serialized by this endpoint
+ * during its lifetime.
+ *
+ * @return total Bytes serialized.
+ * @throws IOException Throws IOException.
+ */
+ Long getBytesSerialized() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControl.java
new file mode 100755
index 0000000..6dc52ac
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControl.java
@@ -0,0 +1,50 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.messaging.endpoints.HTTPEndpoint;
+
+/**
+ * The <code>HTTPEndpointControl</code> class is the MBean implemenation
+ * for monitoring and managing a <code>HTTPEndpoint</code> at runtime.
+ *
+ * @author shodgson
+ */
+public class HTTPEndpointControl extends PollingEndpointControl implements
+ HTTPEndpointControlMBean
+{
+ private static final String TYPE = "HTTPEndpoint";
+
+ /**
+ * Constructs a <code>HTTPEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>HTTPEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public HTTPEndpointControl(HTTPEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControlMBean.java
new file mode 100755
index 0000000..fce75d2
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/HTTPEndpointControlMBean.java
@@ -0,0 +1,27 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+/**
+ * Defines the runtime monitoring and management interface for managed HTTP endpoints.
+ *
+ * @author shodgson
+ */
+public interface HTTPEndpointControlMBean extends PollingEndpointControlMBean
+{
+ // Empty for now.
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControl.java
new file mode 100755
index 0000000..7cdbb74
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControl.java
@@ -0,0 +1,72 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.endpoints.BasePollingHTTPEndpoint;
+
+/**
+ * The <tt>PollingEndpointControl</tt> class is the base MBean implementation
+ * for monitoring and managing a <tt>BasePollingHTTPEndpoint</tt> at runtime.
+ */
+public abstract class PollingEndpointControl extends EndpointControl implements
+ PollingEndpointControlMBean
+{
+ /**
+ * Constructs a <tt>PollingEndpointControl</tt>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>BasePollingHTTPEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public PollingEndpointControl(BasePollingHTTPEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ protected void onRegistrationComplete()
+ {
+ super.onRegistrationComplete();
+
+ String name = this.getObjectName().getCanonicalName();
+ String[] generalPollables = {"WaitingPollRequestsCount"};
+
+ getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_POLLABLE, name, generalPollables);
+ getRegistrar().registerObject(AdminConsoleTypes.ENDPOINT_SCALAR, name, "MaxWaitingPollRequests");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.PollingEndpointControlMBean#getMaxWaitingPollRequests()
+ */
+ public Integer getMaxWaitingPollRequests()
+ {
+ int maxWaitingPollRequests = ((BasePollingHTTPEndpoint)endpoint).getMaxWaitingPollRequests();
+ return new Integer(maxWaitingPollRequests);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.PollingEndpointControlMBean#getWaitingPollRequestsCount()
+ */
+ public Integer getWaitingPollRequestsCount()
+ {
+ int waitingPollRequestsCount = ((BasePollingHTTPEndpoint)endpoint).getWaitingPollRequestsCount();
+ return new Integer(waitingPollRequestsCount);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControlMBean.java
new file mode 100755
index 0000000..016b276
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/PollingEndpointControlMBean.java
@@ -0,0 +1,45 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import java.io.IOException;
+
+/**
+ * Defines the runtime monitoring and management interface for managed polling
+ * endpoints.
+ */
+public interface PollingEndpointControlMBean extends EndpointControlMBean
+{
+ /**
+ * Returns the maximum number of server poll response threads that will be
+ * waiting for messages to arrive for clients.
+ *
+ * @return The maximum number of server poll response threads that will be
+ * waiting for messages to arrive for clients.
+ * @throws IOException Throws IOException.
+ */
+ Integer getMaxWaitingPollRequests() throws IOException;
+
+ /**
+ * Returns the number of request threads that are currently in the wait state
+ * (including those on their way into or out of it).
+ *
+ * @return The number of request threads that are currently in the wait state.
+ * @throws IOException Throws IOException.
+ */
+ Integer getWaitingPollRequestsCount() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControl.java
new file mode 100755
index 0000000..15b29bc
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControl.java
@@ -0,0 +1,48 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.messaging.endpoints.StreamingAMFEndpoint;
+
+/**
+ * The <code>StreamingAMFEndpointControl</code> class is the MBean implemenation
+ * for monitoring and managing an <code>StreamingAMFEndpoint</code> at runtime.
+ */
+public class StreamingAMFEndpointControl extends StreamingEndpointControl implements
+ StreamingAMFEndpointControlMBean
+{
+ private static final String TYPE = "StreamingAMFEndpoint";
+
+ /**
+ * Constructs a <code>StreamingAMFEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>StreamingAMFEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public StreamingAMFEndpointControl(StreamingAMFEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControlMBean.java
new file mode 100755
index 0000000..fffa29b
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingAMFEndpointControlMBean.java
@@ -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 flex.management.runtime.messaging.endpoints;
+
+/**
+ * Defines the runtime monitoring and management interface for managed streaming
+ * AMF endpoints.
+ */
+public interface StreamingAMFEndpointControlMBean extends StreamingEndpointControlMBean
+{
+ // Empty for now
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControl.java
new file mode 100755
index 0000000..1d50bb8
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControl.java
@@ -0,0 +1,133 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import java.util.Date;
+
+import flex.management.BaseControl;
+import flex.management.runtime.AdminConsoleTypes;
+import flex.messaging.endpoints.BaseStreamingHTTPEndpoint;
+
+/**
+ * The <code>StreamingEndpointControl</code> class is the base MBean implementation
+ * for monitoring and managing a <code>BaseStreamingHTTPEndpoint</code> at runtime.
+ */
+public abstract class StreamingEndpointControl extends EndpointControl implements
+ StreamingEndpointControlMBean
+{
+ private int pushCount;
+ private Date lastPushTimeStamp;
+ private long pushStart;
+
+ /**
+ * Constructs a <code>StreamingEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>BaseStreamingHTTPEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public StreamingEndpointControl(BaseStreamingHTTPEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ protected void onRegistrationComplete()
+ {
+ super.onRegistrationComplete();
+
+ String name = this.getObjectName().getCanonicalName();
+ String[] generalPollables = { "LastPushTimestamp", "PushCount", "PushFrequency", "StreamingClientsCount"};
+
+ getRegistrar().registerObjects(AdminConsoleTypes.ENDPOINT_POLLABLE, name, generalPollables);
+ getRegistrar().registerObject(AdminConsoleTypes.ENDPOINT_SCALAR, name, "MaxStreamingClients");
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getMaxStreamingClients()
+ */
+ public Integer getMaxStreamingClients()
+ {
+ int maxStreamingClientsCount = ((BaseStreamingHTTPEndpoint)endpoint).getMaxStreamingClients();
+ return new Integer(maxStreamingClientsCount);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getPushCount()
+ */
+ public Integer getPushCount()
+ {
+ return new Integer(pushCount);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#resetPushCount()
+ */
+ public void resetPushCount()
+ {
+ pushStart = System.currentTimeMillis();
+ pushCount = 0;
+ lastPushTimeStamp = null;
+ }
+
+ /**
+ * Increments the count of messages pushed by the endpoint.
+ */
+ public void incrementPushCount()
+ {
+ ++pushCount;
+ lastPushTimeStamp = new Date();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getLastPushTimestamp()
+ */
+ public Date getLastPushTimestamp()
+ {
+ return lastPushTimeStamp;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#getPushFrequency()
+ */
+ public Double getPushFrequency()
+ {
+ if (pushCount > 0)
+ {
+ double runtime = differenceInMinutes(pushStart, System.currentTimeMillis());
+ return new Double(pushCount/runtime);
+ }
+ else
+ {
+ return new Double(0);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see flex.management.runtime.messaging.endpoints.StreamingEndpointControlMBean#isRunning()
+ */
+ public Integer getStreamingClientsCount()
+ {
+ int streamingClientsCount = ((BaseStreamingHTTPEndpoint)endpoint).getStreamingClientsCount();
+ return new Integer(streamingClientsCount);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControlMBean.java
new file mode 100755
index 0000000..69c6409
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingEndpointControlMBean.java
@@ -0,0 +1,76 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import java.io.IOException;
+import java.util.Date;
+
+/**
+ * Defines the runtime monitoring and management interface for managed streaming
+ * endpoints.
+ */
+public interface StreamingEndpointControlMBean extends EndpointControlMBean
+{
+ /**
+ * Returns the maximum number of clients that will be allowed to establish
+ * a streaming HTTP connection with the endpoint.
+ *
+ * @return The maximum number of clients that will be allowed to establish
+ * a streaming HTTP connection with the endpoint.
+ * @throws IOException Throws IOException.
+ */
+ Integer getMaxStreamingClients() throws IOException;
+
+ /**
+ * Returns the count of push invocations.
+ *
+ * @return The count of push invocations.
+ * @throws IOException Throws IOException.
+ */
+ Integer getPushCount() throws IOException;
+
+ /**
+ * Resets the count of push invocations.
+ *
+ * @throws IOException Throws IOException.
+ */
+ void resetPushCount() throws IOException;
+
+ /**
+ * Returns the timestamp for the most recent push invocation.
+ *
+ * @return The timestamp for the most recent push invocation.
+ * @throws IOException Throws IOException.
+ */
+ Date getLastPushTimestamp() throws IOException;
+
+ /**
+ * Returns the number of push invocations per minute.
+ *
+ * @return The number of push invocations per minute.
+ * @throws IOException Throws IOException.
+ */
+ Double getPushFrequency() throws IOException;
+
+ /**
+ * Returns the the number of clients that are currently in the streaming state.
+ *
+ * @return The number of clients that are currently in the streaming state.
+ * @throws IOException Throws IOException.
+ */
+ Integer getStreamingClientsCount() throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControl.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControl.java
new file mode 100755
index 0000000..1ce6d5d
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControl.java
@@ -0,0 +1,48 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
+
+import flex.management.BaseControl;
+import flex.messaging.endpoints.StreamingHTTPEndpoint;
+
+/**
+ * The <code>StreamingHTTPEndpointControl</code> class is the MBean implemenation
+ * for monitoring and managing a <code>StreamingHTTPEndpoint</code> at runtime.
+ */
+public class StreamingHTTPEndpointControl extends StreamingEndpointControl implements
+ StreamingHTTPEndpointControlMBean
+{
+ private static final String TYPE = "StreamingHTTPEndpoint";
+
+ /**
+ * Constructs a <code>StreamingHTTPEndpointControl</code>, assigning managed message
+ * endpoint and parent MBean.
+ *
+ * @param endpoint The <code>StreamingHTTPEndpoint</code> managed by this MBean.
+ * @param parent The parent MBean in the management hierarchy.
+ */
+ public StreamingHTTPEndpointControl(StreamingHTTPEndpoint endpoint, BaseControl parent)
+ {
+ super(endpoint, parent);
+ }
+
+ /** {@inheritDoc} */
+ public String getType()
+ {
+ return TYPE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControlMBean.java b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControlMBean.java
new file mode 100755
index 0000000..449253a
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/StreamingHTTPEndpointControlMBean.java
@@ -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 flex.management.runtime.messaging.endpoints;
+
+/**
+ * Defines the runtime monitoring and management interface for managed streaming
+ * HTTP endpoints.
+ */
+public interface StreamingHTTPEndpointControlMBean extends StreamingEndpointControlMBean
+{
+ // Empty for now
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/endpoints/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/endpoints/package-info.java b/modules/core/src/flex/management/runtime/messaging/endpoints/package-info.java
new file mode 100755
index 0000000..c04121d
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/endpoints/package-info.java
@@ -0,0 +1,17 @@
+/*
+ * 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 flex.management.runtime.messaging.endpoints;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/log/LogControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/log/LogControl.java b/modules/core/src/flex/management/runtime/messaging/log/LogControl.java
new file mode 100755
index 0000000..ab26864
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/log/LogControl.java
@@ -0,0 +1,149 @@
+/*
+ * 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 flex.management.runtime.messaging.log;
+
+import flex.management.BaseControl;
+import flex.messaging.log.AbstractTarget;
+import flex.messaging.log.Log;
+import flex.messaging.log.Target;
+
+/**
+ * The <code>LogControl</code> class is the MBean implemenation
+ * for monitoring and managing a <code>Log</code> at runtime through the <code>LogManager</code>.
+ * @author majacobs
+ *
+ */
+public class LogControl extends BaseControl implements
+ LogControlMBean
+{
+
+ private static final String TYPE = "Log"; // The type registered with the mbean server
+ private LogManager logManager; // Reference to the LogManager which interfaces with Log
+
+
+ /**
+ * Creates the mbean and registers it with the mbean server.
+ *
+ * @param parent BaseControl
+ * @param manager A reference to the LogManager
+ */
+ public LogControl(BaseControl parent, LogManager manager)
+ {
+ super(parent);
+ this.logManager = manager;
+ register();
+ }
+
+
+ /**
+ * Sets the logging level for the target associated with the unique ID searchId.
+ * @param searchId the search ID
+ * @param level the log level
+ */
+ public void changeTargetLevel(String searchId, String level)
+ {
+ Target selectedTarget = Log.getTarget(searchId);
+ if (selectedTarget != null)
+ {
+ selectedTarget.setLevel(new Short(level).shortValue());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.BaseControl#getId()
+ */
+ public String getId()
+ {
+ return logManager.getId();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.BaseControl#getType()
+ */
+ public String getType()
+ {
+ return TYPE;
+ }
+
+ /**
+ * Return a string array of the loggers.
+ * @return a string array of loggers
+ */
+ public String[] getLoggers()
+ {
+ return logManager.getLoggers();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#getTargets()
+ */
+ public String[] getTargets()
+ {
+ return logManager.getTargetIds();
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#addFilterForTarget(java.lang.String, java.lang.String)
+ */
+ public void addFilterForTarget(String targetId, String filter)
+ {
+ AbstractTarget target = (AbstractTarget) logManager.getTarget(targetId);
+
+ if (target != null && logManager.checkFilter(filter))
+ target.addFilter(filter);
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#getTargetFilters(java.lang.String)
+ */
+ public String[] getTargetFilters(String targetId)
+ {
+ return logManager.getTargetFilters(targetId);
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#removeFilterForTarget(java.lang.String, java.lang.String)
+ */
+ public void removeFilterForTarget(String targetId, String filter)
+ {
+ AbstractTarget target = (AbstractTarget) logManager.getTarget(targetId);
+
+ if (target != null && target.containsFilter(filter))
+ target.removeFilter(filter);
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.runtime.messaging.log.LogControlMBean#getCategories()
+ */
+ public String[] getCategories()
+ {
+ return (String[]) logManager.getCategories().toArray(new String[0]);
+ }
+
+
+ public Integer getTargetLevel(String searchId)
+ {
+ AbstractTarget target = (AbstractTarget) logManager.getTarget(searchId);
+
+ if (target != null)
+ {
+ return new Integer(target.getLevel());
+ } else
+ return new Integer(-1);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/log/LogControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/log/LogControlMBean.java b/modules/core/src/flex/management/runtime/messaging/log/LogControlMBean.java
new file mode 100755
index 0000000..b4b129f
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/log/LogControlMBean.java
@@ -0,0 +1,80 @@
+/*
+ * 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 flex.management.runtime.messaging.log;
+
+import flex.management.BaseControlMBean;
+
+
+/**
+ * Defines the exposed properties and operations of the LogControl.
+ */
+public interface LogControlMBean extends BaseControlMBean
+{
+ /**
+ * Returns the array of log targets.
+ *
+ * @return The array of log targets.
+ */
+ String[] getTargets();
+
+ /**
+ * Returns the array of log target filters.
+ *
+ * @param targetId The target id.
+ * @return The array of log target filters.
+ */
+ String[] getTargetFilters(String targetId);
+
+ /**
+ * Returns the array of log categories.
+ *
+ * @return The array of log categories.
+ */
+ String[] getCategories();
+
+ /**
+ * Returns the target level.
+ *
+ * @param targetId The target id.
+ * @return The target level.
+ */
+ Integer getTargetLevel(String targetId);
+
+ /**
+ * Changes the target level.
+ *
+ * @param targetId The target id.
+ * @param level The target level.
+ */
+ void changeTargetLevel(String targetId, String level);
+
+ /**
+ * Adds a filter for the target.
+ *
+ * @param filter The filter.
+ * @param targetId The target id.
+ */
+ void addFilterForTarget(String filter, String targetId);
+
+ /**
+ * Removes a filter from the target.
+ *
+ * @param filter The filter.
+ * @param targetId The target id.
+ */
+ void removeFilterForTarget(String filter, String targetId);
+}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/7a58369c/modules/core/src/flex/management/runtime/messaging/log/LogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/runtime/messaging/log/LogManager.java b/modules/core/src/flex/management/runtime/messaging/log/LogManager.java
new file mode 100755
index 0000000..d6b72bc
--- /dev/null
+++ b/modules/core/src/flex/management/runtime/messaging/log/LogManager.java
@@ -0,0 +1,266 @@
+/*
+ * 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 flex.management.runtime.messaging.log;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.lang.reflect.Field;
+
+import flex.management.ManageableComponent;
+import flex.messaging.config.ConfigurationException;
+import flex.messaging.log.Log;
+import flex.messaging.log.LogCategories;
+import flex.messaging.log.Target;
+
+
+/**
+ * The LogManager is an interface between the Log and the LogControl which exists
+ * because Log lives in the common package, so it cannot extend ManageableComponent itself,
+ * which is necessary for a class to be exposed through MBeans.
+ *
+ * @author majacobs
+ *
+ */
+public class LogManager extends ManageableComponent
+{
+
+ private static final String LOG_CATEGORY = LogCategories.CONFIGURATION; // Log category used by LogManager (ManageableComponent)
+ private static final int NULL_LOG_REF_EXCEPTION = 10031;
+
+ private Log log;
+ private String ID = "log";
+ private CategoryManager categoryManager;
+ private LogControl controller;
+
+ private boolean isSetup;
+
+ /**
+ * Public constructor required by ManageableComponent.
+ */
+ public LogManager()
+ {
+ this(true);
+ }
+
+ public LogManager(boolean enableManagement)
+ {
+ super(enableManagement);
+ setId(ID);
+
+ categoryManager = new CategoryManager();
+
+ }
+
+
+ public void setupLogControl()
+ {
+ if (!isSetup)
+ {
+ controller = new LogControl(getParent().getControl(), this);
+ setControl(controller);
+ controller.register();
+ isSetup = true;
+ }
+ }
+
+ public void stop()
+ {
+ if (!isStarted())
+ {
+ return;
+ }
+
+
+ super.stop();
+
+ // Remove management
+ if (isManaged())
+ {
+ if (getControl() != null)
+ {
+ getControl().unregister();
+ setControl(null);
+ }
+ setManaged(false);
+ }
+ }
+
+ public void setLog(Log logInstance)
+ {
+ log = logInstance;
+ }
+
+ /* (non-Javadoc)
+ * @see flex.management.ManageableComponent#getLogCategory()
+ */
+ protected String getLogCategory()
+ {
+ return LOG_CATEGORY;
+ }
+
+ /**
+ * Gets the Loggers as a string array.
+ * @return a String array
+ */
+ public String[] getLoggers()
+ {
+ return log.getLoggers();
+ }
+
+ /**
+ * Gets the Target IDs.
+ * @return a string array
+ */
+ public String[] getTargetIds()
+ {
+ return (String[]) Log.getTargetMap().keySet().toArray(new String[0]);
+ }
+
+ /**
+ * Get a Target for a targetId.
+ *
+ * @param targetId the target ID
+ * @return the target from the Log, or null if it is not found
+ */
+ public Target getTarget(String targetId)
+ {
+ return (Target) Log.getTargetMap().get(targetId);
+ }
+
+ /**
+ * Gets the filters for a given target.
+ * @param targetId the target ID
+ * @return a string array
+ */
+ public String[] getTargetFilters(String targetId)
+ {
+
+ Target target = getTarget(targetId);
+
+ if (target == null)
+ return new String[0];
+
+ List filterObjects = target.getFilters();
+ String[] filters = new String[filterObjects.size()];
+ for (int i = 0; i < filterObjects.size(); i++)
+ {
+ filters[i] = (String)filterObjects.get(i);
+ }
+
+ return filters;
+ }
+
+ /**
+ * Check whether a filter is valid.
+ * @param filter the filter string to check
+ * @return whether the category exists in LogCategories
+ */
+ public boolean checkFilter(String filter)
+ {
+ return categoryManager.checkFilter(filter);
+ }
+
+ /**
+ * Return a list of categories in LogCategories.
+ * @return the list of categories in LogCategories
+ */
+ public List getCategories()
+ {
+ return categoryManager.getCategories();
+ }
+
+ protected void validate()
+ {
+ if (isValid())
+ return;
+
+ super.validate();
+
+ if (log == null)
+ {
+ invalidate();
+ ConfigurationException ex = new ConfigurationException();
+ ex.setMessage(NULL_LOG_REF_EXCEPTION, new Object[]{});
+ throw ex;
+ }
+
+ }
+
+ /**
+ * This private class keeps track of what categories exist in LogCategories by implementing
+ * LogCategories and reflecting the interface's properties.
+ *
+ * @author majacobs
+ *
+ */
+ private class CategoryManager implements LogCategories
+ {
+ private List categories;
+
+ /**
+ * Construct an ArrayList for each category in the reflected public properties
+ * Note this will be incorrect if additional public properties are added to this class
+ * or to the interface LogCategories.
+ */
+ public CategoryManager()
+ {
+ categories = new ArrayList();
+
+ Field[] categoryFields = this.getClass().getFields();
+ for (int i = 0; i < categoryFields.length; i++)
+ {
+ try
+ {
+ categories.add((String)categoryFields[i].get(this));
+ }
+ catch (IllegalAccessException iae)
+ {
+ // Illegal Access on reflection
+ }
+ }
+ }
+
+
+ /**
+ * Check if any categories match with the filter (the filter is valid or not).
+ * @param filter the filter string to check
+ * @return whether the filter is valid (with or without a trailing .*)
+ */
+ public boolean checkFilter(String filter)
+ {
+
+ for (int i = 0; i < categories.size(); i++)
+ {
+ if (Log.checkFilterToCategory((String)filter, (String)categories.get(i)))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Return a list of log categories.
+ * @return List a list of the categories
+ */
+ public List getCategories()
+ {
+ return Collections.unmodifiableList(new ArrayList(categories));
+ }
+ }
+}