From ec3e46b1dd260e46b60c7bb6c60ddf322f7968d1 Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 16 May 2011 08:28:50 +0000 Subject: Correct typo in package name git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1103645 13f79535-47bb-0310-9956-ffa450edef68 --- .../HazelcastClientDomainRegistryFactory.java | 49 ++++++++ .../client/HazelcastClientEndpointRegistry.java | 130 +++++++++++++++++++++ .../HazelcastClientDomainRegistryFactory.java | 49 -------- .../client/HazelcastClientEndpointRegistry.java | 130 --------------------- 4 files changed, 179 insertions(+), 179 deletions(-) create mode 100644 sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientDomainRegistryFactory.java create mode 100644 sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java delete mode 100644 sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/regsitry/hazelcast/client/HazelcastClientDomainRegistryFactory.java delete mode 100644 sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/regsitry/hazelcast/client/HazelcastClientEndpointRegistry.java (limited to 'sca-java-2.x/trunk/modules/domain-hazelcast/src/main') diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientDomainRegistryFactory.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientDomainRegistryFactory.java new file mode 100644 index 0000000000..5193b577da --- /dev/null +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientDomainRegistryFactory.java @@ -0,0 +1,49 @@ +/* + * 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.tuscany.sca.registry.hazelcast.client; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.runtime.BaseDomainRegistryFactory; +import org.apache.tuscany.sca.runtime.DomainRegistry; + +/** + * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the + * given domain + */ +public class HazelcastClientDomainRegistryFactory extends BaseDomainRegistryFactory { + private final static String[] schemes = new String[] {"hazelcastclient", "tuscanyclient"}; + + /** + * @param extensionRegistry + */ + public HazelcastClientDomainRegistryFactory(ExtensionPointRegistry registry) { + super(registry); + } + + protected DomainRegistry createEndpointRegistry(String endpointRegistryURI, String domainURI) { + DomainRegistry domainRegistry = + new HazelcastClientEndpointRegistry(registry, null, endpointRegistryURI, domainURI); + return domainRegistry; + } + + public String[] getSupportedSchemes() { + return schemes; + } +} diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java new file mode 100644 index 0000000000..5def8c2dd2 --- /dev/null +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java @@ -0,0 +1,130 @@ +/* + * 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.tuscany.sca.registry.hazelcast.client; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.Socket; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRegistry; +import org.apache.tuscany.sca.registry.hazelcast.RegistryConfig; +import org.apache.tuscany.sca.runtime.RuntimeProperties; + +import com.hazelcast.client.ClientProperties; +import com.hazelcast.client.ClientProperties.ClientPropertyName; +import com.hazelcast.client.HazelcastClient; +import com.hazelcast.core.HazelcastInstance; + +/** + * An DomainRegistry using a Hazelcast Native Client + */ +public class HazelcastClientEndpointRegistry extends HazelcastDomainRegistry { + + RegistryConfig rc; + HazelcastClient hazelcastClient; + + public HazelcastClientEndpointRegistry(ExtensionPointRegistry registry, + Map attributes, + String domainRegistryURI, + String domainURI) { + super(registry, attributes, domainRegistryURI, domainURI); + } + + @Override + public void start() { + if (endpointMap != null) { + throw new IllegalStateException("The registry has already been started"); + } + initHazelcastClientInstance(); + endpointMap = hazelcastClient.getMap(rc.getUserid() + "/Endpoints"); + endpointOwners = hazelcastClient.getMultiMap(rc.getUserid() + "/EndpointOwners"); + } + + @Override + public void stop() { + if (hazelcastClient != null) { + hazelcastClient.shutdown(); + hazelcastClient = null; + endpointMap = null; + } + } + + private void initHazelcastClientInstance() { + if (this.domainURI == null) { + this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties(); + this.domainURI = properties.getProperty("defaultDomainName", "default"); + } + this.rc = RegistryConfig.parseConfigURI(domainURI); + if (rc.getWKAs().size() < 1) { + String ip = getDefaultWKA(); + if (ip != null) { + rc.getWKAs().add(ip); + } + } + if (rc.getWKAs().size() < 1) { + throw new IllegalArgumentException("No local domain instance found, please use domain URI 'wka=' argument to define IP address(es) for domain"); + } + + // Hazelcast is outputs a lot on info level log messages which are unnecessary for us, + // so disable info logging for hazelcast client classes unless fine logging is on for tuscany. + if (!Logger.getLogger(this.getClass().getName()).isLoggable(Level.CONFIG)) { + Logger hzl = Logger.getLogger("com.hazelcast"); + if (!hzl.isLoggable(Level.FINE)) { + hzl.setLevel(Level.WARNING); + } + } + + ClientProperties clientProps = ClientProperties.crateBaseClientProperties(rc.getUserid(), rc.getPassword()); + clientProps.setPropertyValue(ClientPropertyName.INIT_CONNECTION_ATTEMPTS_LIMIT, "1"); + this.hazelcastClient = HazelcastClient.newHazelcastClient(clientProps, rc.getWKAs().toArray(new String[0])); + } + + @Override + public HazelcastInstance getHazelcastInstance() { + return hazelcastClient; + } + + /** + * As a default connect to a local runtime instance listening on port 14820 + */ + protected static String getDefaultWKA() { + Socket s = null; + try { + s = new Socket(InetAddress.getLocalHost(), 14820); + if (s.isConnected()) { + return s.getInetAddress().getHostAddress() + ":14820"; + } + } catch (IOException e) { + } finally { + if (s != null) { + try { + s.close(); + } catch (IOException e) { + } + } + } + return null; + } +} diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/regsitry/hazelcast/client/HazelcastClientDomainRegistryFactory.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/regsitry/hazelcast/client/HazelcastClientDomainRegistryFactory.java deleted file mode 100644 index 104cf928e5..0000000000 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/regsitry/hazelcast/client/HazelcastClientDomainRegistryFactory.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.tuscany.sca.regsitry.hazelcast.client; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.runtime.BaseDomainRegistryFactory; -import org.apache.tuscany.sca.runtime.DomainRegistry; - -/** - * The utility responsible for finding the endpoint regstry by the scheme and creating instances for the - * given domain - */ -public class HazelcastClientDomainRegistryFactory extends BaseDomainRegistryFactory { - private final static String[] schemes = new String[] {"hazelcastclient", "tuscanyclient"}; - - /** - * @param extensionRegistry - */ - public HazelcastClientDomainRegistryFactory(ExtensionPointRegistry registry) { - super(registry); - } - - protected DomainRegistry createEndpointRegistry(String endpointRegistryURI, String domainURI) { - DomainRegistry domainRegistry = - new HazelcastClientEndpointRegistry(registry, null, endpointRegistryURI, domainURI); - return domainRegistry; - } - - public String[] getSupportedSchemes() { - return schemes; - } -} diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/regsitry/hazelcast/client/HazelcastClientEndpointRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/regsitry/hazelcast/client/HazelcastClientEndpointRegistry.java deleted file mode 100644 index e11f0a07e4..0000000000 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/regsitry/hazelcast/client/HazelcastClientEndpointRegistry.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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.tuscany.sca.regsitry.hazelcast.client; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.Socket; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.registry.hazelcast.HazelcastDomainRegistry; -import org.apache.tuscany.sca.registry.hazelcast.RegistryConfig; -import org.apache.tuscany.sca.runtime.RuntimeProperties; - -import com.hazelcast.client.ClientProperties; -import com.hazelcast.client.ClientProperties.ClientPropertyName; -import com.hazelcast.client.HazelcastClient; -import com.hazelcast.core.HazelcastInstance; - -/** - * An DomainRegistry using a Hazelcast Native Client - */ -public class HazelcastClientEndpointRegistry extends HazelcastDomainRegistry { - - RegistryConfig rc; - HazelcastClient hazelcastClient; - - public HazelcastClientEndpointRegistry(ExtensionPointRegistry registry, - Map attributes, - String domainRegistryURI, - String domainURI) { - super(registry, attributes, domainRegistryURI, domainURI); - } - - @Override - public void start() { - if (endpointMap != null) { - throw new IllegalStateException("The registry has already been started"); - } - initHazelcastClientInstance(); - endpointMap = hazelcastClient.getMap(rc.getUserid() + "/Endpoints"); - endpointOwners = hazelcastClient.getMultiMap(rc.getUserid() + "/EndpointOwners"); - } - - @Override - public void stop() { - if (hazelcastClient != null) { - hazelcastClient.shutdown(); - hazelcastClient = null; - endpointMap = null; - } - } - - private void initHazelcastClientInstance() { - if (this.domainURI == null) { - this.properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties(); - this.domainURI = properties.getProperty("defaultDomainName", "default"); - } - this.rc = RegistryConfig.parseConfigURI(domainURI); - if (rc.getWKAs().size() < 1) { - String ip = getDefaultWKA(); - if (ip != null) { - rc.getWKAs().add(ip); - } - } - if (rc.getWKAs().size() < 1) { - throw new IllegalArgumentException("No local domain instance found, please use domain URI 'wka=' argument to define IP address(es) for domain"); - } - - // Hazelcast is outputs a lot on info level log messages which are unnecessary for us, - // so disable info logging for hazelcast client classes unless fine logging is on for tuscany. - if (!Logger.getLogger(this.getClass().getName()).isLoggable(Level.CONFIG)) { - Logger hzl = Logger.getLogger("com.hazelcast"); - if (!hzl.isLoggable(Level.FINE)) { - hzl.setLevel(Level.WARNING); - } - } - - ClientProperties clientProps = ClientProperties.crateBaseClientProperties(rc.getUserid(), rc.getPassword()); - clientProps.setPropertyValue(ClientPropertyName.INIT_CONNECTION_ATTEMPTS_LIMIT, "1"); - this.hazelcastClient = HazelcastClient.newHazelcastClient(clientProps, rc.getWKAs().toArray(new String[0])); - } - - @Override - public HazelcastInstance getHazelcastInstance() { - return hazelcastClient; - } - - /** - * As a default connect to a local runtime instance listening on port 14820 - */ - protected static String getDefaultWKA() { - Socket s = null; - try { - s = new Socket(InetAddress.getLocalHost(), 14820); - if (s.isConnected()) { - return s.getInetAddress().getHostAddress() + ":14820"; - } - } catch (IOException e) { - } finally { - if (s != null) { - try { - s.close(); - } catch (IOException e) { - } - } - } - return null; - } -} -- cgit v1.2.3