Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jbossDeploymentUtil
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Даурен Топаев
jbossDeploymentUtil
Commits
781e2b50
Commit
781e2b50
authored
Oct 11, 2016
by
natalya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial commit
parents
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
390 additions
and
0 deletions
+390
-0
.gitignore
.gitignore
+15
-0
pom.xml
pom.xml
+60
-0
Config.java
src/main/java/kz/arta/ext/jdm/config/Config.java
+80
-0
DeploymentsDirectoryObserver.java
.../kz/arta/ext/jdm/config/DeploymentsDirectoryObserver.java
+19
-0
DeploymentsList.java
src/main/java/kz/arta/ext/jdm/config/DeploymentsList.java
+42
-0
DirectoryViewer.java
src/main/java/kz/arta/ext/jdm/config/DirectoryViewer.java
+50
-0
FileUtil.java
src/main/java/kz/arta/ext/jdm/config/FileUtil.java
+32
-0
Deployment.java
src/main/java/kz/arta/ext/jdm/config/model/Deployment.java
+36
-0
Deployments.java
src/main/java/kz/arta/ext/jdm/config/model/Deployments.java
+27
-0
ConfigTest.java
src/test/java/kz/arta/ext/jdm/config/ConfigTest.java
+24
-0
config.xml
src/test/resources/kz/arta/jdm/config/config.xml
+5
-0
No files found.
.gitignore
0 → 100644
View file @
781e2b50
# Intellij
.idea/
*.iml
*.iws
# Mac
.DS_Store
# Maven
log/
target/
# Maven release plugin files
release.properties
pom.xml.releaseBackup
pom.xml
0 → 100644
View file @
781e2b50
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
kz.arta.ext
</groupId>
<artifactId>
jboss-deployments-manager
</artifactId>
<version>
1.0.0-SNAPSHOT
</version>
<packaging>
jar
</packaging>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
1.6
</maven.compiler.source>
<maven.compiler.target>
1.6
</maven.compiler.target>
<powermock.version>
1.6.5
</powermock.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
1.7.21
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
<version>
1.7.21
</version>
</dependency>
<dependency>
<groupId>
org.powermock
</groupId>
<artifactId>
powermock-module-junit4
</artifactId>
<version>
${powermock.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.powermock
</groupId>
<artifactId>
powermock-module-testng
</artifactId>
<version>
${powermock.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.powermock
</groupId>
<artifactId>
powermock-api-mockito
</artifactId>
<version>
${powermock.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
<version>
6.9.10
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
src/main/java/kz/arta/ext/jdm/config/Config.java
0 → 100644
View file @
781e2b50
package
kz
.
arta
.
ext
.
jdm
.
config
;
import
kz.arta.ext.jdm.config.model.Deployment
;
import
kz.arta.ext.jdm.config.model.Deployments
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.xml.bind.JAXB
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
/**
* Created by timur on 10/10/16.
*/
public
class
Config
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Config
.
class
);
private
String
filePath
=
"/opt/synergy/jdm/deployments.xml"
;
private
String
deploymentsPath
=
"/opt/synergy/jboss/standalone/deployments"
;
private
String
tmpPath
=
"/opt/tmpDeployments"
;
private
Deployments
deployments
;
private
Config
()
{
readConfig
();
}
private
static
Config
config
=
null
;
public
static
Config
getInstance
()
{
if
(
config
==
null
)
{
config
=
new
Config
();
}
return
config
;
}
private
void
readConfig
()
{
FileInputStream
fin
=
null
;
try
{
ByteArrayOutputStream
bout
=
new
ByteArrayOutputStream
();
fin
=
new
FileInputStream
(
filePath
);
byte
[]
buffer
=
new
byte
[
1024
];
int
read
;
while
((
read
=
fin
.
read
(
buffer
,
0
,
buffer
.
length
))
!=
-
1
)
{
bout
.
write
(
buffer
,
0
,
read
);
}
deployments
=
JAXB
.
unmarshal
(
new
ByteArrayInputStream
(
bout
.
toByteArray
()),
Deployments
.
class
);
}
catch
(
Exception
exc
){
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
finally
{
try
{
fin
.
close
();
}
catch
(
IOException
e
)
{
LOGGER
.
error
(
e
.
getMessage
(),
e
);
}
}
}
public
String
getDeploymentsPath
()
{
return
deploymentsPath
;
}
public
String
getTmpPath
()
{
return
tmpPath
;
}
public
Deployments
getDeployments
()
{
return
deployments
;
}
}
src/main/java/kz/arta/ext/jdm/config/DeploymentsDirectoryObserver.java
0 → 100644
View file @
781e2b50
package
kz
.
arta
.
ext
.
jdm
.
config
;
/**
* Created by timur on 10/10/16.
*/
public
class
DeploymentsDirectoryObserver
extends
Thread
{
private
DirectoryViewer
viewer
=
new
DirectoryViewer
();
private
FileUtil
fileUtil
=
new
FileUtil
();
@Override
public
void
run
()
{
}
}
src/main/java/kz/arta/ext/jdm/config/DeploymentsList.java
0 → 100644
View file @
781e2b50
package
kz
.
arta
.
ext
.
jdm
.
config
;
import
kz.arta.ext.jdm.config.model.Deployment
;
import
kz.arta.ext.jdm.config.model.Deployments
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
/**
* Created by timur on 10/11/16.
*/
public
class
DeploymentsList
{
private
HashMap
<
String
,
DeploymentItem
>
items
=
new
HashMap
<>();
public
DeploymentsList
(
Deployments
deployments
)
{
for
(
Deployment
deployment:
deployments
.
getDeployments
())
{
DeploymentItem
item
=
null
;
if
(
items
.
containsKey
(
deployment
.
getName
()))
{
item
=
items
.
get
(
deployment
.
getName
());
}
else
{
item
=
new
DeploymentItem
();
item
.
fileName
=
deployment
.
getName
();
items
.
put
(
item
.
fileName
,
item
);
}
item
.
dependsOnList
.
add
(
deployment
.
getDependsOn
());
}
}
private
class
DeploymentItem
{
String
fileName
;
List
<
String
>
dependsOnList
=
new
ArrayList
<>();
boolean
isDeployed
;
}
}
src/main/java/kz/arta/ext/jdm/config/DirectoryViewer.java
0 → 100644
View file @
781e2b50
package
kz
.
arta
.
ext
.
jdm
.
config
;
import
kz.arta.ext.jdm.config.model.Deployment
;
import
kz.arta.ext.jdm.config.model.Deployments
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
/**
* Created by timur on 10/10/16.
*/
public
class
DirectoryViewer
{
private
List
<
String
>
getDeployedList
()
{
String
[]
files
=
new
File
(
Config
.
getInstance
().
getDeploymentsPath
()).
list
();
HashSet
<
String
>
deploymentsSet
=
new
HashSet
();
HashSet
<
String
>
serviceFilesSet
=
new
HashSet
();
for
(
String
file:
files
)
{
if
(
file
.
endsWith
(
"ear"
)
||
file
.
endsWith
(
"jar"
)
||
file
.
endsWith
(
"war"
))
{
deploymentsSet
.
add
(
file
);
}
else
{
serviceFilesSet
.
add
(
file
);
}
}
List
<
String
>
deployedList
=
new
ArrayList
<
String
>();
for
(
String
str:
deploymentsSet
)
{
if
(
serviceFilesSet
.
contains
(
str
+
".deployed"
))
{
deployedList
.
add
(
str
);
}
}
return
deployedList
;
}
public
List
<
String
>
getReadyToDeployList
()
{
List
<
String
>
deployed
=
getDeployedList
();
Deployments
deployments
=
Config
.
getInstance
().
getDeployments
();
for
(
Deployment
deployment:
deployments
.
getDeployments
())
{
}
return
null
;
}
}
src/main/java/kz/arta/ext/jdm/config/FileUtil.java
0 → 100644
View file @
781e2b50
package
kz
.
arta
.
ext
.
jdm
.
config
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.nio.file.*
;
/**
* Created by timur on 10/10/16.
*/
public
class
FileUtil
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
FileUtil
.
class
);
public
void
moveFileBeforeStart
(
String
fileName
)
{
try
{
Files
.
move
(
FileSystems
.
getDefault
().
getPath
(
Config
.
getInstance
().
getDeploymentsPath
(),
fileName
),
FileSystems
.
getDefault
().
getPath
(
Config
.
getInstance
().
getTmpPath
()),
StandardCopyOption
.
REPLACE_EXISTING
);
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
public
void
moveFileOnDeployed
(
String
fileName
)
{
try
{
Files
.
move
(
FileSystems
.
getDefault
().
getPath
(
Config
.
getInstance
().
getTmpPath
(),
fileName
),
FileSystems
.
getDefault
().
getPath
(
Config
.
getInstance
().
getDeploymentsPath
()),
StandardCopyOption
.
REPLACE_EXISTING
);
}
catch
(
Exception
exc
)
{
LOGGER
.
error
(
exc
.
getMessage
(),
exc
);
}
}
}
src/main/java/kz/arta/ext/jdm/config/model/Deployment.java
0 → 100644
View file @
781e2b50
package
kz
.
arta
.
ext
.
jdm
.
config
.
model
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
import
java.util.List
;
/**
* Created by topa on 10/10/16.
*/
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
Deployment
{
@XmlAttribute
(
name
=
"name"
)
private
String
name
;
@XmlAttribute
(
name
=
"dependsOn"
)
private
String
dependsOn
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDependsOn
()
{
return
dependsOn
;
}
public
void
setDependsOn
(
String
dependsOn
)
{
this
.
dependsOn
=
dependsOn
;
}
}
src/main/java/kz/arta/ext/jdm/config/model/Deployments.java
0 → 100644
View file @
781e2b50
package
kz
.
arta
.
ext
.
jdm
.
config
.
model
;
import
javax.xml.bind.annotation.XmlAccessType
;
import
javax.xml.bind.annotation.XmlAccessorType
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlRootElement
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Created by timur on 10/10/16.
*/
@XmlRootElement
(
name
=
"deployments"
)
@XmlAccessorType
(
XmlAccessType
.
FIELD
)
public
class
Deployments
{
@XmlElement
(
name
=
"deployment"
)
private
List
<
Deployment
>
deployments
=
new
ArrayList
<
Deployment
>();
public
List
<
Deployment
>
getDeployments
()
{
return
deployments
;
}
public
void
setDeployments
(
List
<
Deployment
>
deployments
)
{
this
.
deployments
=
deployments
;
}
}
src/test/java/kz/arta/ext/jdm/config/ConfigTest.java
0 → 100644
View file @
781e2b50
package
kz
.
arta
.
ext
.
jdm
.
config
;
import
kz.arta.ext.jdm.config.model.Deployments
;
import
org.powermock.api.mockito.PowerMockito
;
import
org.powermock.reflect.Whitebox
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
/**
* Created by timur on 10/10/16.
*/
public
class
ConfigTest
{
@Test
public
void
testReadConfig
()
throws
Exception
{
Config
config
=
PowerMockito
.
mock
(
Config
.
class
);
Whitebox
.
setInternalState
(
config
,
"filePath"
,
ConfigTest
.
class
.
getResource
(
"/kz/arta/jdm/config/config.xml"
).
getFile
());
Whitebox
.
invokeMethod
(
config
,
"readConfig"
);
Deployments
deployments
=
Whitebox
.
getInternalState
(
config
,
"deployments"
);
Assert
.
assertEquals
(
deployments
.
getDeployments
().
size
(),
2
);
}
}
src/test/resources/kz/arta/jdm/config/config.xml
0 → 100644
View file @
781e2b50
<deployments>
<deployment
name=
"ear1"
dependsOn=
"ear0"
/>
<deployment
name=
"ear2"
dependsOn=
"ear1"
/>
</deployments>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment