-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change grid address and codec factory
- Loading branch information
息羽
committed
Mar 7, 2016
1 parent
0c96e5e
commit e5b3a76
Showing
34 changed files
with
540 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/** | ||
* | ||
* Copyright 2015 The Darks Grid Project (Liu lihua) | ||
* | ||
* 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 darks.grid.beans; | ||
|
||
import java.io.Serializable; | ||
import java.net.InetSocketAddress; | ||
import java.net.SocketAddress; | ||
|
||
import darks.grid.utils.StringUtils; | ||
|
||
public class GridAddress implements Serializable | ||
{ | ||
|
||
/** | ||
* | ||
*/ | ||
private static final long serialVersionUID = -715203941820641100L; | ||
|
||
private String hostName; | ||
|
||
private int port; | ||
|
||
public GridAddress() | ||
{ | ||
|
||
} | ||
|
||
public GridAddress(InetSocketAddress addr) | ||
{ | ||
this(addr.getHostName(), addr.getPort()); | ||
} | ||
|
||
public GridAddress(String hostName, int port) | ||
{ | ||
this.hostName = hostName; | ||
this.port = port; | ||
} | ||
|
||
public InetSocketAddress getSocketAddress() | ||
{ | ||
return new InetSocketAddress(hostName, port); | ||
} | ||
|
||
public static GridAddress wrap(InetSocketAddress addr) | ||
{ | ||
return new GridAddress(addr); | ||
} | ||
|
||
public static GridAddress wrap(SocketAddress addr) | ||
{ | ||
return wrap((InetSocketAddress) addr); | ||
} | ||
|
||
public String getHostName() { | ||
return hostName; | ||
} | ||
|
||
public void setHostName(String hostName) { | ||
this.hostName = hostName; | ||
} | ||
|
||
public int getPort() { | ||
return port; | ||
} | ||
|
||
public void setPort(int port) { | ||
this.port = port; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return StringUtils.stringBuffer(hostName, ':', port); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((hostName == null) ? 0 : hostName.hashCode()); | ||
result = prime * result + port; | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
GridAddress other = (GridAddress) obj; | ||
if (hostName == null) { | ||
if (other.hostName != null) | ||
return false; | ||
} else if (!hostName.equals(other.hostName)) | ||
return false; | ||
if (port != other.port) | ||
return false; | ||
return true; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* | ||
* Copyright 2015 The Darks Grid Project (Liu lihua) | ||
* | ||
* 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 darks.grid.config; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import darks.grid.network.codec.GridCodec; | ||
|
||
public class CodecConfig | ||
{ | ||
|
||
|
||
|
||
private String type; | ||
|
||
private Class<? extends GridCodec> codecClass = null; | ||
|
||
private Map<String, String> parameters = new HashMap<String, String>(); | ||
|
||
public CodecConfig() | ||
{ | ||
|
||
} | ||
|
||
public void addParameter(String key, String value) | ||
{ | ||
parameters.put(key, value); | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public Class<? extends GridCodec> getCodecClass() { | ||
return codecClass; | ||
} | ||
|
||
public void setCodecClass(Class<? extends GridCodec> codecClass) { | ||
this.codecClass = codecClass; | ||
} | ||
|
||
public Map<String, String> getParameters() { | ||
return parameters; | ||
} | ||
|
||
public void setParameters(Map<String, String> parameters) { | ||
this.parameters = parameters; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.