Updated Branches: refs/heads/javelin a06eb4557 -> b38d9b82b
CloudStack messaging refactoring skeleton Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/b38d9b82 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/b38d9b82 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/b38d9b82 Branch: refs/heads/javelin Commit: b38d9b82b6de3f240f96281f61854dd114cdd261 Parents: a06eb45 Author: Kelven Yang <kelv...@gmail.com> Authored: Tue Nov 13 17:59:11 2012 -0800 Committer: Kelven Yang <kelv...@gmail.com> Committed: Tue Nov 13 17:59:39 2012 -0800 ---------------------------------------------------------------------- framework/events/.project | 17 ---- .../framework/messaging/ComponentEndpoint.java | 75 +++++++++++++++ .../cloudstack/framework/messaging/RpcCall.java | 27 +++++ .../framework/messaging/RpcCallHandler.java | 30 ++++++ .../framework/messaging/RpcEndpoint.java | 26 +++++ .../framework/messaging/RpcProvider.java | 24 +++++ .../messaging/TransportAddressFactory.java | 23 +++++ .../framework/messaging/TransportEndpoint.java | 29 ++++++ .../framework/messaging/TransportMultiplexier.java | 24 +++++ .../framework/messaging/TransportProvider.java | 24 +++++ .../messaging/client/ClientTransportEndpoint.java | 47 +++++++++ .../messaging/client/ClientTransportProvider.java | 35 +++++++ .../messaging/server/ServerTransportProvider.java | 37 +++++++ framework/jobs/.project | 23 ----- .../src/com/cloud/servlet/CloudStartupServlet.java | 54 +++++++++++ 15 files changed, 455 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/events/.project ---------------------------------------------------------------------- diff --git a/framework/events/.project b/framework/events/.project deleted file mode 100755 index 677cea5..0000000 --- a/framework/events/.project +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>framework-events</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/ComponentEndpoint.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/ComponentEndpoint.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/ComponentEndpoint.java new file mode 100644 index 0000000..0c55b30 --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/ComponentEndpoint.java @@ -0,0 +1,75 @@ +/* + * 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.cloudstack.framework.messaging; + +public class ComponentEndpoint implements RpcEndpoint, TransportMultiplexier { + + private TransportEndpoint transportEndpoint; + private RpcProvider rpcProvider; + + public ComponentEndpoint() { + } + + public TransportEndpoint getTransportEndpoint() { + return transportEndpoint; + } + + public void setTransportEndpoint(TransportEndpoint transportEndpoint) { + this.transportEndpoint = transportEndpoint; + } + + public RpcProvider getRpcProvider() { + return rpcProvider; + } + + public void setRpcProvider(RpcProvider rpcProvider) { + this.rpcProvider = rpcProvider; + } + + public void initialize(String[] multiplexiers) { + if(multiplexiers != null) { + for(String name : multiplexiers) + transportEndpoint.registerMultiplexier(name, this); + } + + rpcProvider.registerRpcEndpoint(this); + } + + @Override + public void onTransportMessage(String senderEndpointAddress, + String targetEndpointAddress, String multiplexer, String message) { + } + + @Override + public String call(String targetAddress, String rpcMessage) { + // TODO Auto-generated method stub + return null; + } + + @Override + public void asyncCall(String targetAddress, String rpcMessage) { + // TODO Auto-generated method stub + } + + @Override + public void onCall(RpcCall call) { + // TODO Auto-generated method stub + + } +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcCall.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcCall.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcCall.java new file mode 100644 index 0000000..be16bdd --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcCall.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 org.apache.cloudstack.framework.messaging; + +public interface RpcCall { + String getCommand(); + String getContent(); + String getRequestTag(); + + void completeCall(String rpcMessage); +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcCallHandler.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcCallHandler.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcCallHandler.java new file mode 100644 index 0000000..2d94064 --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcCallHandler.java @@ -0,0 +1,30 @@ +/* + * 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.cloudstack.framework.messaging; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface RpcCallHandler { + String command(); +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcEndpoint.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcEndpoint.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcEndpoint.java new file mode 100644 index 0000000..62dc973 --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcEndpoint.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 org.apache.cloudstack.framework.messaging; + +public interface RpcEndpoint { + public String call(String targetAddress, String rpcMessage); + public void asyncCall(String targetAddress, String rpcMessage); + + void onCall(RpcCall call); +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcProvider.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcProvider.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcProvider.java new file mode 100644 index 0000000..cbdd4a7 --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/RpcProvider.java @@ -0,0 +1,24 @@ +/* + * 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.cloudstack.framework.messaging; + +public interface RpcProvider extends TransportMultiplexier { + public void registerRpcEndpoint(RpcEndpoint rpcEndpoint); + public void unregisteRpcEndpoint(RpcEndpoint rpcEndpoint); +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportAddressFactory.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportAddressFactory.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportAddressFactory.java new file mode 100644 index 0000000..d7f3e9d --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportAddressFactory.java @@ -0,0 +1,23 @@ +/* + * 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.cloudstack.framework.messaging; + +public interface TransportAddressFactory { + String createServiceAddress(String serviceProvider); +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportEndpoint.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportEndpoint.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportEndpoint.java new file mode 100644 index 0000000..68982e2 --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportEndpoint.java @@ -0,0 +1,29 @@ +/* + * 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.cloudstack.framework.messaging; + +public interface TransportEndpoint { + void onAttachConfirm(String endpointAddress); + + void registerMultiplexier(String name, TransportMultiplexier multiplexier); + void unregisterMultiplexier(String name); + + void sendMessage(TransportEndpoint sender, String targetEndpointAddress, + String multiplexier, String message); +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportMultiplexier.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportMultiplexier.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportMultiplexier.java new file mode 100644 index 0000000..2e8e570 --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportMultiplexier.java @@ -0,0 +1,24 @@ +/* + * 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.cloudstack.framework.messaging; + +public interface TransportMultiplexier { + public void onTransportMessage(String senderEndpointAddress, String targetEndpointAddress, + String multiplexer, String message); +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportProvider.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportProvider.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportProvider.java new file mode 100644 index 0000000..6773e8d --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/TransportProvider.java @@ -0,0 +1,24 @@ +/* + * 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.cloudstack.framework.messaging; + +public interface TransportProvider { + void attach(TransportEndpoint endpoint, String predefinedAddress); + void detach(TransportEndpoint endpoint); +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/client/ClientTransportEndpoint.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/client/ClientTransportEndpoint.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/client/ClientTransportEndpoint.java new file mode 100644 index 0000000..8ee4b8f --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/client/ClientTransportEndpoint.java @@ -0,0 +1,47 @@ +/* + * 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.cloudstack.framework.messaging.client; + +import org.apache.cloudstack.framework.messaging.TransportEndpoint; +import org.apache.cloudstack.framework.messaging.TransportMultiplexier; + +public class ClientTransportEndpoint implements TransportEndpoint { + + @Override + public void onAttachConfirm(String endpointAddress) { + // TODO Auto-generated method stub + } + + @Override + public void registerMultiplexier(String name, + TransportMultiplexier multiplexier) { + // TODO Auto-generated method stub + } + + @Override + public void unregisterMultiplexier(String name) { + // TODO Auto-generated method stub + } + + @Override + public void sendMessage(TransportEndpoint sender, + String targetEndpointAddress, String multiplexier, String message) { + // TODO Auto-generated method stub + } +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/client/ClientTransportProvider.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/client/ClientTransportProvider.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/client/ClientTransportProvider.java new file mode 100644 index 0000000..665d207 --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/client/ClientTransportProvider.java @@ -0,0 +1,35 @@ +/* + * 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.cloudstack.framework.messaging.client; + +import org.apache.cloudstack.framework.messaging.TransportEndpoint; +import org.apache.cloudstack.framework.messaging.TransportProvider; + +public class ClientTransportProvider implements TransportProvider { + + @Override + public void attach(TransportEndpoint endpoint, String predefinedAddress) { + // TODO Auto-generated method stub + } + + @Override + public void detach(TransportEndpoint endpoint) { + // TODO Auto-generated method stub + } +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/ipc/src/org/apache/cloudstack/framework/messaging/server/ServerTransportProvider.java ---------------------------------------------------------------------- diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messaging/server/ServerTransportProvider.java b/framework/ipc/src/org/apache/cloudstack/framework/messaging/server/ServerTransportProvider.java new file mode 100644 index 0000000..1f7c12b --- /dev/null +++ b/framework/ipc/src/org/apache/cloudstack/framework/messaging/server/ServerTransportProvider.java @@ -0,0 +1,37 @@ +/* + * 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.cloudstack.framework.messaging.server; + +import org.apache.cloudstack.framework.messaging.TransportEndpoint; +import org.apache.cloudstack.framework.messaging.TransportProvider; + +public class ServerTransportProvider implements TransportProvider { + + @Override + public void attach(TransportEndpoint endpoint, String predefinedAddress) { + // TODO Auto-generated method stub + + } + + @Override + public void detach(TransportEndpoint endpoint) { + // TODO Auto-generated method stub + + } +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/framework/jobs/.project ---------------------------------------------------------------------- diff --git a/framework/jobs/.project b/framework/jobs/.project deleted file mode 100755 index ddf0af0..0000000 --- a/framework/jobs/.project +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>cloud-framework-jobs</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.m2e.core.maven2Builder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.m2e.core.maven2Nature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/b38d9b82/server/src/com/cloud/servlet/CloudStartupServlet.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/servlet/CloudStartupServlet.java b/server/src/com/cloud/servlet/CloudStartupServlet.java index e38b923..93b6e00 100755 --- a/server/src/com/cloud/servlet/CloudStartupServlet.java +++ b/server/src/com/cloud/servlet/CloudStartupServlet.java @@ -16,6 +16,9 @@ // under the License. package com.cloud.servlet; +import java.util.Map; +import java.util.Set; + import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.ServletException; @@ -28,7 +31,12 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.server.ConfigurationServer; import com.cloud.server.ManagementServer; import com.cloud.utils.SerialVersionUID; +import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentLocator; +import com.cloud.utils.component.SystemIntegrityChecker; +import com.cloud.utils.component.LegacyComponentLocator.ComponentInfo; +import com.cloud.utils.db.GenericDao; +import com.cloud.utils.db.GenericDaoBase; public class CloudStartupServlet extends HttpServlet implements ServletContextListener { public static final Logger s_logger = Logger.getLogger(CloudStartupServlet.class.getName()); @@ -71,4 +79,50 @@ public class CloudStartupServlet extends HttpServlet implements ServletContextLi @Override public void contextDestroyed(ServletContextEvent sce) { } + + // + // following should be moved to CloudStackServer component later to encapsulate business logic in one place + // + private void initCloudStackComponents() { + runCheckers(); + startDaos(); // daos should not be using managers and adapters. + +/* + configureManagers(); + configureAdapters(); + startManagers(); + startAdapters(); +*/ + } + + private void runCheckers() { + Map<String, SystemIntegrityChecker> checkers = ComponentContext.getApplicationContext().getBeansOfType( + SystemIntegrityChecker.class); + + for(SystemIntegrityChecker checker : checkers.values()) { + try { + checker.check(); + } catch (Exception e) { + s_logger.error("Problems with running checker:" + checker.getClass().getName(), e); + System.exit(1); + } + } + } + + private void startDaos() { + @SuppressWarnings("rawtypes") + Map<String, GenericDaoBase> daos = ComponentContext.getApplicationContext().getBeansOfType( + GenericDaoBase.class); + + for(GenericDaoBase dao : daos.values()) { + try { + + // dao.configure(dao.getClass().getSimpleName(), params); + } catch (Exception e) { + s_logger.error("Problems with running checker:" + dao.getClass().getName(), e); + System.exit(1); + } + } + } + }