[Carbon-dev] svn commit r15228 - in trunk/carbon:
core/src/org/wso2/carbon core/src/org/wso2/carbon/deployment
core/src/org/wso2/carbon/persistence
distribution/carbon-home/repository
svn at wso2.org
svn at wso2.org
Thu Mar 27 04:32:07 PDT 2008
Author: azeez
Date: Thu Mar 27 04:31:49 2008
New Revision: 15228
Log:
Started outting the deployment meta data into the registry
Added:
trunk/carbon/core/src/org/wso2/carbon/CarbonRegistryResources.java
trunk/carbon/core/src/org/wso2/carbon/RegistryTest.java
Modified:
trunk/carbon/core/src/org/wso2/carbon/ServerManager.java
trunk/carbon/core/src/org/wso2/carbon/deployment/DeploymentInterceptor.java
trunk/carbon/core/src/org/wso2/carbon/persistence/PersistenceManager.java
trunk/carbon/distribution/carbon-home/repository/axis2.xml
Added: trunk/carbon/core/src/org/wso2/carbon/CarbonRegistryResources.java
==============================================================================
--- (empty file)
+++ trunk/carbon/core/src/org/wso2/carbon/CarbonRegistryResources.java Thu Mar 27 04:31:49 2008
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.carbon;
+
+/**
+ *
+ */
+public final class CarbonRegistryResources {
+
+ public static final String ROOT = "/carbon/";
+ public static final String TRANSPORTS = ROOT + "transports/";
+ public static final String SERVICE_GROUPS = ROOT + "service-groups/";
+ public static final String MODULES = ROOT + "modules/";
+
+ public static final String SERVICES = "/services/";
+ public static final String OPERATIONS = "/operations/";
+ public static final String MESSAGES = "/messages/";
+ public static final String PARAMETERS = "/parameters/";
+ public static final String POLICIES = "/policies/";
+
+ public static final class ServiceGroupProperties{
+ public static final String LAST_UPDATED = "last.updated";
+ }
+}
Added: trunk/carbon/core/src/org/wso2/carbon/RegistryTest.java
==============================================================================
--- (empty file)
+++ trunk/carbon/core/src/org/wso2/carbon/RegistryTest.java Thu Mar 27 04:31:49 2008
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.carbon;
+
+import org.wso2.registry.Registry;
+import org.wso2.registry.ResourceImpl;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.jdbc.InMemoryJDBCRegistry;
+
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+
+/**
+ *
+ */
+public class RegistryTest {
+ public static void main(String[] args) throws Exception {
+ Registry registry = new InMemoryJDBCRegistry();
+ ResourceImpl resource = new ResourceImpl();
+ resource.setContent("/carbon/service-groups/sg44");
+ registry.put("hh/carbon/service-groups/sg1", null);
+
+ /* try {
+ InputStream inputStream =
+ registry.get("/carbon/service-groups/sg1").getContentStream();
+ BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
+ StringBuffer buffer = new StringBuffer();
+ String line;
+ while ((line = in.readLine()) != null) {
+ buffer.append(line);
+ }
+ System.out.println(buffer.toString());
+ } catch (RegistryException e) {
+ System.out.println("------------");
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }*/
+ }
+}
Modified: trunk/carbon/core/src/org/wso2/carbon/ServerManager.java
==============================================================================
--- trunk/carbon/core/src/org/wso2/carbon/ServerManager.java (original)
+++ trunk/carbon/core/src/org/wso2/carbon/ServerManager.java Thu Mar 27 04:31:49 2008
@@ -79,6 +79,8 @@
System.getProperty(ServerConstants.WEB_RESOURCE_LOCATION));
}
+ initializeRegistry();
+
// initLoggingConfiguration();
persistSecurityKeyStore();
@@ -109,8 +111,6 @@
runIntializers();
- initializeRegistry();
-
try {
ServerStatus.setServerRunning();
} catch (AxisFault e) {
Modified: trunk/carbon/core/src/org/wso2/carbon/deployment/DeploymentInterceptor.java
==============================================================================
--- trunk/carbon/core/src/org/wso2/carbon/deployment/DeploymentInterceptor.java (original)
+++ trunk/carbon/core/src/org/wso2/carbon/deployment/DeploymentInterceptor.java Thu Mar 27 04:31:49 2008
@@ -45,6 +45,8 @@
//import org.wso2.carbon.security.ServerCrypto;
//import org.wso2.carbon.security.util.RampartConfigUtil;
import org.wso2.carbon.util.SystemFilter;
+import org.wso2.carbon.CarbonRegistryResources;
+import org.wso2.registry.Resource;
import java.util.ArrayList;
import java.util.Collection;
@@ -79,32 +81,33 @@
int eventType = axisEvent.getEventType();
if (eventType == AxisEvent.SERVICE_DEPLOY) {
- ServiceGroupDO sgDO =
+ Resource serviceGroup =
persistenceMgr.getServiceGroup(axisServiceGroup.getServiceGroupName());
- if (sgDO == null) {
+ if (serviceGroup == null) {
addServiceGroup(axisServiceGroup);
} else {
// Check whether the artifact has been updated, if so we need to purge all
// database entries and treat this as a new service group addition
- if (!sgDO.getServiceArtifactUpdateTime().
+ //TODO: AZEEZ
+ /*if (! new Long(serviceGroup.getProperty(CarbonRegistryResources.ServiceGroupProperties.LAST_UPDATED)).
equals(CarbonUtils.lastUpdatedTime(axisServiceGroup))) {
log.warn("The service artifact of the " +
axisServiceGroup.getServiceGroupName() +
- " service group has changed. Removing all database entries and " +
+ " service group has changed. Removing all registry entries and " +
"handling this as a new service addition.");
deleteServiceGroup(axisServiceGroup);
addServiceGroup(axisServiceGroup);
} else {
try {
- persistenceMgr.handleExistingServiceGroupInit(sgDO, axisServiceGroup);
+ persistenceMgr.handleExistingServiceGroupInit(serviceGroup, axisServiceGroup);
} catch (Exception e) {
String msg = "Could not handle initialization of existing service group [" +
axisServiceGroup.getServiceGroupName() + "]";
log.error(msg, e);
}
- }
+ }*/
}
} else if (eventType == AxisEvent.SERVICE_REMOVE) {
deleteServiceGroup(axisServiceGroup);
@@ -140,11 +143,10 @@
if (axisService.isClientSide()) {
return;
}
- //TODO: For the moment, there is no serviceDO version handling facility. hence we'll use
- // EMPTY_SERVICE_VERSION for all services
int eventType = axisEvent.getEventType();
- String serviceName = axisService.getName();
+ //TODO AZEEZ
+ /*String serviceName = axisService.getName();
String serviceVersion = ServiceIdentifierDO.EMPTY_SERVICE_VERSION;
ServiceDO serviceDO = persistenceMgr.getService(serviceName, serviceVersion);
@@ -174,94 +176,12 @@
log.error(msg, e);
}
}
- } else {
-
- // STS specific configurations
- if (axisService.getName().equals(ServerConstants.STS_NAME)
- && axisEvent.getEventType() == AxisEvent.SERVICE_DEPLOY) {
-
- // Add the STS Service
- ServerConfiguration config = ServerConfiguration.getInstance();
- KeyStoreDO[] keystores = persistenceMgr.getKeyStores();
- KeyStoreDO sysKs = null;
- for (int i = 0; i < keystores.length; i++) {
- if (keystores[i].getIsPrimaryKeyStore()) {
- sysKs = keystores[i];
- break;
- }
- }
- if (sysKs != null) {
- String issuerName = config.getFirstProperty("HostName"); //TODO: Is this correct?
- if (issuerName == null) {
- //HostName not set :-( use wso2wsas-sts
- issuerName = ServerConstants.STS_NAME;
- }
- /*String cryptoProvider = ServerCrypto.class.getName();
- String ksId = sysKs.getKeyStoreName();
- Properties props = RampartConfigUtil.getServerCryptoProperties(
- new String[]{ksId}, ksId, sysKs.getPrivateKeyAlias());
-
- SAMLTokenIssuerConfig stsSamlConfig = new SAMLTokenIssuerConfig(
- issuerName, cryptoProvider, props);
- stsSamlConfig.setIssuerKeyAlias(config.getFirstProperty("Security.KeyStore.KeyAlias"));
- stsSamlConfig.setIssuerKeyPassword(config.getFirstProperty("Security.KeyStore.KeyPassword"));
- stsSamlConfig.setAddRequestedAttachedRef(true);
- stsSamlConfig.setAddRequestedUnattachedRef(true);
- stsSamlConfig.setKeyComputation(2);
- stsSamlConfig.setProofKeyType(TokenIssuerUtil.BINARY_SECRET);
- try {
- //remove param is exists
- Parameter param = axisService.getParameter(SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
- if (param == null) {
- //Add new parameter
- axisService.addParameter(stsSamlConfig.getParameter());
- }
- } catch (AxisFault e) {
- log.error("Error setting STS-SAML configuration parameter", e);
- }*/
- }
- }
-
- // Else, this is a AxisEvent.SERVICE_DEPLOY event.
- // This may be a new or existing serviceDO
- if (serviceDO == null) { // is this a new serviceDO? If so, register it in the DB
- try {
- persistenceMgr.handleNewServiceAddition(axisService);
- } catch (Exception e) {
- String msg = "Could not handle initialization of new service [" +
- axisService.getName() + "]";
- log.error(msg, e);
- }
- } else { // The serviceDO is already registered in the DB
- try {
- persistenceMgr.handleExistingServiceInit(serviceDO, axisService, axisConfig);
- } catch (Exception e) {
- String msg = "Could not handle initialization of existing service [" +
- axisService.getName() + "]";
- log.error(msg, e);
- }
- }
- }
- }
-
-
- private void removeEJBServiceConfiguration(AxisService axisService) {
- String serviceType = (String) axisService.getParameterValue(ServerConstants.SERVICE_TYPE);
- if (ServerConstants.SERVICE_TYPE_EJB.equals(serviceType)) {
- //No need for a NULL check.Its mandatory for a EJB service to have these params
- String beanJNDIName = (String) (axisService.getParameter(EJBUtil.EJB_JNDI_NAME)).getValue();
- String jnpProviderUrl = (String) (axisService.getParameter(EJBUtil.EJB_PROVIDER_URL)).getValue();
- try {
- persistenceMgr.removeEJBConfiguration(beanJNDIName, jnpProviderUrl);
- } catch (EJBConfigurationNotFoundException e) {
- log.error(e.getMessage());
- }
- }
+ } */
}
public void moduleUpdate(AxisEvent axisEvent, AxisModule axisModule) {
-
- // We ignore admin module events
+ //TODO AZEEZ
+ /*// We ignore admin module events
String moduleName = axisModule.getName();
if (moduleName.equals(ServerConstants.ADMIN_MODULE) ||
moduleName.equals(ServerConstants.TRACER_MODULE) ||
@@ -293,7 +213,7 @@
} catch (Exception e) {
log.error("Could not handle addition of new module", e);
}
- }
+ }*/
}
public void addParameter(Parameter parameter) throws AxisFault {
Modified: trunk/carbon/core/src/org/wso2/carbon/persistence/PersistenceManager.java
==============================================================================
--- trunk/carbon/core/src/org/wso2/carbon/persistence/PersistenceManager.java (original)
+++ trunk/carbon/core/src/org/wso2/carbon/persistence/PersistenceManager.java Thu Mar 27 04:31:49 2008
@@ -35,9 +35,8 @@
import org.apache.neethi.PolicyRegistry;
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.wso2.carbon.utils.ServerConfigurator;
-import org.wso2.carbon.utils.CarbonUtils;
-import org.wso2.carbon.utils.ServerConstants;
+import org.wso2.carbon.ServerManager;
+import org.wso2.carbon.CarbonRegistryResources;
import org.wso2.carbon.persistence.dao.AppenderDAO;
import org.wso2.carbon.persistence.dao.BaseDAO;
import org.wso2.carbon.persistence.dao.EJBAppServerDAO;
@@ -48,7 +47,6 @@
import org.wso2.carbon.persistence.dao.ModuleDAO;
import org.wso2.carbon.persistence.dao.OperationDAO;
import org.wso2.carbon.persistence.dao.SecurityScenarioDAO;
-//import org.wso2.carbon.persistence.dao.SecurityTokenDAO;
import org.wso2.carbon.persistence.dao.ServerConfigurationDAO;
import org.wso2.carbon.persistence.dao.ServiceDAO;
import org.wso2.carbon.persistence.dao.ServiceGroupDAO;
@@ -69,7 +67,6 @@
import org.wso2.carbon.persistence.dataobject.OperationDO;
import org.wso2.carbon.persistence.dataobject.OperationParameterDO;
import org.wso2.carbon.persistence.dataobject.SecurityScenarioDO;
-//import org.wso2.carbon.persistence.dataobject.SecurityTokenDO;
import org.wso2.carbon.persistence.dataobject.ServiceDO;
import org.wso2.carbon.persistence.dataobject.ServiceGroupDO;
import org.wso2.carbon.persistence.dataobject.ServiceGroupParameterDO;
@@ -96,13 +93,19 @@
import org.wso2.carbon.persistence.exception.ServicePolicyNotFoundException;
import org.wso2.carbon.persistence.exception.ServiceUserAlreadyExistsException;
import org.wso2.carbon.persistence.exception.ServiceUserNotFoundException;
-import org.wso2.carbon.persistence.exception.TokenAlreadyExistsException;
import org.wso2.carbon.persistence.exception.TransportAlreadyExistsException;
import org.wso2.carbon.persistence.exception.UserRoleAlreadyExistsException;
-//import org.wso2.carbon.security.WSS4JUtil;
import org.wso2.carbon.util.HibernateConfig;
import org.wso2.carbon.util.HibernateConfigFactory;
import org.wso2.carbon.util.ParameterUtil;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.wso2.carbon.utils.ServerConfigurator;
+import org.wso2.carbon.utils.ServerConstants;
+import org.wso2.registry.Registry;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.Resource;
+import org.wso2.registry.ResourceImpl;
+import org.wso2.registry.exceptions.ResourceNotFoundException;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLOutputFactory;
@@ -110,6 +113,11 @@
import javax.xml.stream.XMLStreamWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
@@ -121,6 +129,7 @@
public class PersistenceManager {
private HibernateConfig hbConfig;
private static Log log = LogFactory.getLog(PersistenceManager.class);
+ private Registry registry = ServerManager.getInstance().getRegistry();
public PersistenceManager() {
this.hbConfig =
@@ -292,8 +301,16 @@
new ServiceGroupDAO(hbConfig).createServiceGroup(sgDO);
}
- public ServiceGroupDO getServiceGroup(String serviceGroupId) {
- return new ServiceGroupDAO(hbConfig).getServiceGroup(serviceGroupId);
+ public Resource getServiceGroup(String serviceGroupId) {
+ try {
+ return registry.get(CarbonRegistryResources.SERVICE_GROUPS + serviceGroupId);
+ }catch(ResourceNotFoundException e){
+ return null;
+ } catch (RegistryException e) {
+ String msg = "Could not get service group from registry";
+ log.error(msg);
+ throw new RuntimeException(msg, e);
+ }
}
public ServiceDO[] getServices(ServiceGroupDO serviceGroup) {
@@ -1045,7 +1062,7 @@
log.error("Unable to handle service initialization", e);
tx.rollback();
throw e;
- }
+ }
}
private boolean isGloballyEngaged(String moduleId, String moduleVersion, Session session) {
@@ -1129,18 +1146,18 @@
if (services.hasNext() && ((AxisService) services.next()).isClientSide()) {
return;
}
- ServiceGroupDO sgDO = new ServiceGroupDO();
- sgDO.setServiceArtifactUpdateTime(CarbonUtils.lastUpdatedTime(serviceGroup));
+ Resource sgDO = new ResourceImpl();
+ sgDO.addProperty(CarbonRegistryResources.ServiceGroupProperties.LAST_UPDATED,
+ CarbonUtils.lastUpdatedTime(serviceGroup).toString());
String sgName = serviceGroup.getServiceGroupName();
- sgDO.setName(sgName);
- Session session = hbConfig.currentSession();
- Transaction tx = session.beginTransaction();
+ sgDO.setContent(sgName);
AxisConfiguration axisConfiguration = serviceGroup.getAxisConfiguration();
try {
- ModuleDAO moduleDAO = new ModuleDAO(hbConfig);
+// ModuleDAO moduleDAO = new ModuleDAO(hbConfig);
// Handle ServiceGroup-Module engagement
- for (Iterator iter = serviceGroup.getEngagedModules().iterator(); iter.hasNext();) {
+ //TODO: AZEEZ handle this when the Registry impl is ready
+ /*for (Iterator iter = serviceGroup.getEngagedModules().iterator(); iter.hasNext();) {
AxisModule axisModule = (AxisModule) iter.next();
if (!axisConfiguration.isEngaged(axisModule.getName())) {
ModuleDO moduleDO =
@@ -1151,10 +1168,11 @@
sgDO.addModule(moduleDO);
}
}
- }
+ }*/
// Handle Service Group Parameters
- for (Iterator iter = serviceGroup.getParameters().iterator(); iter.hasNext();) {
+ //TODO: AZEEZ handle this when the Registry impl is ready
+ /*for (Iterator iter = serviceGroup.getParameters().iterator(); iter.hasNext();) {
Parameter parameter = (Parameter) iter.next();
if (parameter.getName() != null && parameter.getName().trim().length() != 0) {
ServiceGroupParameterDO paramDO = new ServiceGroupParameterDO();
@@ -1162,17 +1180,14 @@
if (parameter.getParameterElement() != null) {
paramDO.setValue(parameter.getParameterElement().toString());
paramDO.setServiceGroup(sgDO);
-// session.persist(paramDO);
}
}
- }
- new ServiceGroupDAO(hbConfig).createServiceGroup(sgDO, session);
- tx.commit();
+ }*/
+ registry.put(CarbonRegistryResources.SERVICE_GROUPS + sgName, sgDO);
} catch (Exception e) {
log.error("Unable to handle new service group addition", e);
- tx.rollback();
throw e;
- }
+ }
if (log.isDebugEnabled()) {
log.debug("Added new service group - " + sgName);
}
@@ -1367,7 +1382,7 @@
String msg = "Unable to removeAllLoggersAndAppenders";
log.error(msg, e);
throw new RuntimeException(msg, e);
- }
+ }
}
public Long addEJBConfiguration(EJBProviderDO ejbProvider)
Modified: trunk/carbon/distribution/carbon-home/repository/axis2.xml
==============================================================================
--- trunk/carbon/distribution/carbon-home/repository/axis2.xml (original)
+++ trunk/carbon/distribution/carbon-home/repository/axis2.xml Thu Mar 27 04:31:49 2008
@@ -49,7 +49,7 @@
<!-- This deployment interceptor will be called whenever before a module is initialized or
service is deployed -->
- <!--<listener class="org.wso2.carbon.deployment.DeploymentInterceptor"/>-->
+ <listener class="org.wso2.carbon.deployment.DeploymentInterceptor"/>
<!--<listener class="org.wso2.carbon.feed.FeedListener"/>-->
<!-- setting servicePath-->
More information about the Carbon-dev
mailing list