Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
frascati
frascati
Commits
a3852172
Commit
a3852172
authored
Aug 11, 2010
by
Philippe Merle
Browse files
* Improved the code quality according to checking rules of Sonar.
* Cosmetic updates.
parent
bad64af8
Changes
18
Hide whitespace changes
Inline
Side-by-side
frascati/maven-plugins/frascati-contribution/src/main/java/org/ow2/frascati/mojo/FrascatiContributionMojo.java
View file @
a3852172
/**
*
/**
* OW2 FraSCAti Contribution Maven Plugin
* Copyright (C) 2008-2010 INRIA, University of Lille 1
*
...
...
@@ -113,23 +113,24 @@ public class FrascatiContributionMojo
ouputFile
.
createNewFile
();
FileOutputStream
outputStream
=
new
FileOutputStream
(
ouputFile
);
try
{
String
begin
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<contribution xmlns=\"http://www.osoa.org/xmlns/sca/1.0\">\n"
;
String
end
=
"</contribution>"
;
String
begin
=
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<contribution xmlns=\"http://www.osoa.org/xmlns/sca/1.0\">\n"
;
String
end
=
"</contribution>"
;
String
body
=
""
;
String
body
=
""
;
for
(
String
deployable
:
deployables
)
{
body
=
body
+
" <deployable composite=\""
+
deployable
for
(
String
deployable
:
deployables
)
{
body
=
body
+
" <deployable composite=\""
+
deployable
+
"\"/>\n"
;
getLog
().
info
(
"Added deployable composite : "
+
deployable
);
}
// write contribution file
outputStream
.
write
((
begin
+
body
+
end
).
getBytes
());
outputStream
.
flush
();
outputStream
.
close
();
getLog
().
info
(
"Added deployable composite : "
+
deployable
);
}
// write contribution file
outputStream
.
write
((
begin
+
body
+
end
).
getBytes
());
outputStream
.
flush
();
}
finally
{
outputStream
.
close
();
}
}
catch
(
IOException
e
)
{
getLog
().
error
(
"Could not create contribution descriptor"
);
}
...
...
@@ -193,20 +194,21 @@ public class FrascatiContributionMojo
* @throws IOException
*/
private
void
copy
(
File
inFile
,
File
outFile
)
throws
IOException
{
private
void
copy
(
File
inFile
,
File
outFile
)
throws
IOException
{
FileReader
in
=
new
FileReader
(
inFile
);
FileWriter
out
=
new
FileWriter
(
outFile
);
int
c
;
try
{
int
c
;
// TODO: Could be speedup by using a buffer.
while
((
c
=
in
.
read
())
!=
-
1
)
{
out
.
write
(
c
);
// TODO: Could be speedup by using a buffer.
while
((
c
=
in
.
read
())
!=
-
1
)
{
out
.
write
(
c
);
}
}
finally
{
in
.
close
();
out
.
close
();
}
in
.
close
();
out
.
close
();
}
/**
...
...
@@ -217,35 +219,38 @@ public class FrascatiContributionMojo
* @throws IOException
*/
private
void
zip
(
File
inFile
,
File
outFile
)
throws
IOException
{
private
void
zip
(
File
inFile
,
File
outFile
)
throws
IOException
{
final
int
buffer
=
2048
;
BufferedInputStream
origin
=
null
;
FileOutputStream
dest
=
new
FileOutputStream
(
outFile
);
ZipOutputStream
out
=
new
ZipOutputStream
(
new
BufferedOutputStream
(
dest
));
byte
data
[]
=
new
byte
[
buffer
];
List
<
String
>
list
=
visitFiles
(
inFile
,
new
ArrayList
<
String
>(),
""
);
for
(
String
f
:
list
)
{
FileInputStream
fi
=
new
FileInputStream
(
new
File
(
inFile
,
f
));
origin
=
new
BufferedInputStream
(
fi
,
buffer
);
ZipEntry
entry
=
new
ZipEntry
(
f
);
out
.
putNextEntry
(
entry
);
int
count
;
while
((
count
=
origin
.
read
(
data
,
0
,
buffer
))
!=
-
1
)
{
out
.
write
(
data
,
0
,
count
);
try
{
byte
data
[]
=
new
byte
[
buffer
];
List
<
String
>
list
=
visitFiles
(
inFile
,
new
ArrayList
<
String
>(),
""
);
for
(
String
f
:
list
)
{
FileInputStream
fi
=
new
FileInputStream
(
new
File
(
inFile
,
f
));
BufferedInputStream
origin
=
new
BufferedInputStream
(
fi
,
buffer
);
ZipEntry
entry
=
new
ZipEntry
(
f
);
out
.
putNextEntry
(
entry
);
try
{
int
count
;
while
((
count
=
origin
.
read
(
data
,
0
,
buffer
))
!=
-
1
)
{
out
.
write
(
data
,
0
,
count
);
}
}
finally
{
origin
.
close
();
fi
.
close
();
}
}
o
rigin
.
close
();
}
finally
{
o
ut
.
close
();
dest
.
close
();
}
out
.
close
();
}
private
List
<
String
>
visitFiles
(
File
dir
,
List
<
String
>
files
,
String
currentDir
)
...
...
frascati/modules/frascati-assembly-factory/src/main/java/org/ow2/frascati/assembly/factory/Launcher.java
View file @
a3852172
...
...
@@ -45,8 +45,9 @@ import org.ow2.frascati.util.FrascatiException;
*
* @author Nicolas Dolet
*/
public
class
Launcher
extends
AbstractLoggeable
{
public
class
Launcher
extends
AbstractLoggeable
{
//---------------------------------------------------------------------------
// Internal state.
// --------------------------------------------------------------------------
...
...
@@ -68,7 +69,8 @@ public class Launcher extends AbstractLoggeable {
/**
* Default constructor.
*/
public
Launcher
()
{
public
Launcher
()
{
scaComposite
=
null
;
}
...
...
@@ -79,7 +81,8 @@ public class Launcher extends AbstractLoggeable {
* @throws FrascatiException
*/
public
Launcher
(
String
compositeName
)
throws
FrascatiException
{
throws
FrascatiException
{
try
{
scaComposite
=
FraSCAti
.
newFraSCAti
().
getComposite
(
compositeName
);
this
.
compositeName
=
compositeName
;
...
...
@@ -96,7 +99,8 @@ public class Launcher extends AbstractLoggeable {
* @throws FrascatiException
*/
public
Launcher
(
String
compositeName
,
FraSCAti
f
)
throws
FrascatiException
{
throws
FrascatiException
{
try
{
scaComposite
=
f
.
getComposite
(
compositeName
);
this
.
compositeName
=
compositeName
;
...
...
@@ -115,7 +119,8 @@ public class Launcher extends AbstractLoggeable {
* @throws FrascatiException
*/
public
Launcher
(
String
compositeName
,
FraSCAti
f
,
URL
[]
urls
)
throws
FrascatiException
{
throws
FrascatiException
{
try
{
scaComposite
=
f
.
getComposite
(
compositeName
,
urls
);
this
.
compositeName
=
compositeName
;
...
...
@@ -147,7 +152,8 @@ public class Launcher extends AbstractLoggeable {
* Launch the composite
* @throws FrascatiException
*/
public
final
void
launch
()
throws
FrascatiException
{
public
final
void
launch
()
throws
FrascatiException
{
if
(
compositeName
!=
null
)
{
try
{
scaComposite
=
FraSCAti
.
newFraSCAti
().
getComposite
(
compositeName
);
...
...
@@ -166,7 +172,8 @@ public class Launcher extends AbstractLoggeable {
* @throws FrascatiException
*/
public
final
void
launch
(
String
compositeName
)
throws
FrascatiException
{
throws
FrascatiException
{
this
.
compositeName
=
compositeName
;
launch
();
}
...
...
@@ -187,13 +194,14 @@ public class Launcher extends AbstractLoggeable {
*/
@SuppressWarnings
(
"unchecked"
)
public
final
<
T
>
T
call
(
String
serviceName
,
String
methodName
,
Class
<
T
>
responseType
,
Object
...
params
)
throws
FrascatiException
{
Class
<
T
>
responseType
,
Object
...
params
)
throws
FrascatiException
{
StringBuffer
paramList
=
new
StringBuffer
();
try
{
Object
o
=
TinfiDomain
.
getService
(
scaComposite
,
Object
.
class
,
serviceName
);
Class
<?>
c
=
o
.
getClass
();
Class
<?>[]
paramTypes
;
String
paramList
=
""
;
boolean
withParams
;
if
(
params
==
null
)
{
paramTypes
=
new
Class
[
0
];
...
...
@@ -202,7 +210,7 @@ public class Launcher extends AbstractLoggeable {
paramTypes
=
new
Class
[
params
.
length
];
for
(
int
i
=
0
;
i
<
params
.
length
;
++
i
)
{
paramTypes
[
i
]
=
params
[
i
].
getClass
();
paramList
+=
params
[
i
]
+
" "
;
paramList
.
append
(
params
[
i
]
).
append
(
' '
)
;
}
withParams
=
true
;
}
...
...
@@ -220,7 +228,7 @@ public class Launcher extends AbstractLoggeable {
return
null
;
}
catch
(
NoSuchMethodException
e
)
{
warning
(
new
FrascatiException
(
"The service '"
+
serviceName
+
"' does not provide the method "
+
methodName
+
params
,
e
));
+
"' does not provide the method "
+
methodName
+
'('
+
paramList
.
toString
()
+
')'
,
e
));
return
null
;
}
catch
(
IllegalArgumentException
e
)
{
warning
(
new
FrascatiException
(
e
));
...
...
frascati/modules/frascati-assembly-factory/src/main/java/org/ow2/frascati/assembly/factory/ManifestLauncher.java
View file @
a3852172
/**
* OW2 FraSCAti Assembly Factory
* Copyright (C) 2009 INRIA, SARDES
* Copyright (C) 2009
-2010
INRIA, SARDES
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -20,7 +20,8 @@
*
* Author: Valerio Schiavoni
*
* Contributor(s):
* Contributor(s): Philippe Merle
*
*/
package
org.ow2.frascati.assembly.factory
;
...
...
@@ -69,12 +70,15 @@ import org.ow2.frascati.util.FrascatiException;
* @see http://maven.apache.org/plugins/maven-assembly-plugin/
* @see http://ant.apache.org/manual/CoreTasks/jar.html
*/
public
class
ManifestLauncher
{
public
class
ManifestLauncher
{
protected
ManifestLauncher
()
{
private
ManifestLauncher
()
{
}
public
static
void
main
(
String
[]
args
)
throws
IOException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
// mainComposite : the name of the main composite file
// mainService: the name of the main service
// mainMethod: the name of the method to call
...
...
@@ -90,12 +94,13 @@ public class ManifestLauncher {
JarFile
jar
=
new
JarFile
(
jarFileName
);
if
(
jar
==
null
)
{
// create a Manifest obj
Manifest
mf
=
jar
.
getManifest
();
if
(
mf
==
null
)
{
throw
new
IllegalStateException
(
"Cannot read "
+
jarFileName
+
":!META-INF/MANIFEST.MF from "
+
jarFileName
);
}
// create a Manifest obj
Manifest
mf
=
jar
.
getManifest
();
final
Attributes
mainAttributes
=
mf
.
getMainAttributes
();
// get the mainComposite attribute value
...
...
frascati/modules/frascati-assembly-factory/src/main/java/org/ow2/frascati/assembly/factory/manager/AssemblyFactoryManager.java
View file @
a3852172
...
...
@@ -84,8 +84,8 @@ import org.ow2.frascati.util.FrascatiException;
public
class
AssemblyFactoryManager
extends
AbstractFractalLoggeable
<
ManagerException
>
implements
ClassLoaderManager
,
CompositeManager
{
CompositeManager
{
//---------------------------------------------------------------------------
// Internal state.
// --------------------------------------------------------------------------
...
...
@@ -149,7 +149,8 @@ public class AssemblyFactoryManager
* @see AbstractFractalLoggeable#newException(String)
*/
@Override
protected
final
ManagerException
newException
(
String
message
)
{
protected
final
ManagerException
newException
(
String
message
)
{
return
new
ManagerException
(
message
);
}
...
...
@@ -212,7 +213,8 @@ public class AssemblyFactoryManager
* Initialization.
*/
@Init
public
final
void
initialize
()
throws
FrascatiException
{
public
final
void
initialize
()
throws
FrascatiException
{
// init the FraSCAti class loader used.
setClassLoader
(
new
FrascatiClassLoader
());
// create the top level domain composite.
...
...
@@ -220,24 +222,11 @@ public class AssemblyFactoryManager
setFractalComponentName
(
topLevelDomainComposite
,
"Top Level Domain Composite"
);
}
/**
* Finalization.
*/
public
final
void
finalize
()
throws
Throwable
{
this
.
contributionParser
=
null
;
this
.
compositeParser
=
null
;
this
.
membraneGeneration
=
null
;
this
.
compositeProcessor
=
null
;
this
.
mainClassLoader
=
null
;
this
.
topLevelDomainComposite
=
null
;
this
.
loadedComposites
=
null
;
super
.
finalize
();
}
/**
* @see org.ow2.frascati.assembly.factory.api.ClassLoaderManager#getClassLoader()
*/
public
final
URLClassLoader
getClassLoader
()
{
public
final
URLClassLoader
getClassLoader
()
{
return
this
.
mainClassLoader
;
}
...
...
@@ -328,14 +317,14 @@ public class AssemblyFactoryManager
}
}
catch
(
MalformedURLException
e
)
{
severe
(
new
ManagerException
(
e
));
return
n
ull
;
return
n
ew
Component
[
0
]
;
}
catch
(
IOException
e
)
{
severe
(
new
ManagerException
(
e
));
return
n
ull
;
return
n
ew
Component
[
0
]
;
}
if
(
scaContribution
==
null
)
{
return
n
ull
;
return
n
ew
Component
[
0
]
;
}
ArrayList
<
Component
>
components
=
new
ArrayList
<
Component
>();
...
...
@@ -358,7 +347,7 @@ public class AssemblyFactoryManager
}
catch
(
ParserException
pe
)
{
severe
(
new
ManagerException
(
"Error when loading the contribution file "
+
contribution
+
" with the SCA XML Processor"
,
pe
));
return
n
ull
;
return
n
ew
Component
[
0
]
;
}
// Iterate over 'Deployable' defined in contribution descriptor
...
...
@@ -368,7 +357,7 @@ public class AssemblyFactoryManager
components
.
add
(
c
);
}
catch
(
Exception
exc
)
{
severe
(
new
ManagerException
(
"Error when loading the composite "
+
deployable
.
getComposite
(),
exc
));
return
n
ull
;
return
n
ew
Component
[
0
]
;
}
}
// return loaded components
...
...
frascati/modules/frascati-assembly-factory/src/main/java/org/ow2/frascati/assembly/factory/processor/AbstractProcessorManager.java
View file @
a3852172
...
...
@@ -45,8 +45,8 @@ import org.ow2.frascati.assembly.factory.api.ProcessorException;
* @version 1.3
*/
public
abstract
class
AbstractProcessorManager
<
ElementType
extends
EObject
>
extends
AbstractProcessor
<
ElementType
>
{
extends
AbstractProcessor
<
ElementType
>
{
//---------------------------------------------------------------------------
// Internal state.
// --------------------------------------------------------------------------
...
...
@@ -54,12 +54,12 @@ public abstract class AbstractProcessorManager<ElementType extends EObject>
/**
* List of processors.
*/
private
List
<
Processor
<
ElementType
>>
processors
;
private
List
<
Processor
<
ElementType
>>
processors
=
null
;
/**
* Map indexing processors by their processor ID.
*/
private
Map
<
String
,
Processor
<
ElementType
>>
processorsByID
;
private
Map
<
String
,
Processor
<
ElementType
>>
processorsByID
=
null
;
//---------------------------------------------------------------------------
// Internal methods.
...
...
@@ -68,7 +68,8 @@ public abstract class AbstractProcessorManager<ElementType extends EObject>
/**
* Set the list of processors.
*/
protected
final
void
setProcessors
(
List
<
Processor
<
ElementType
>>
processors
)
{
protected
final
void
setProcessors
(
List
<
Processor
<
ElementType
>>
processors
)
{
this
.
processors
=
processors
;
this
.
processorsByID
=
null
;
}
...
...
@@ -140,7 +141,8 @@ public abstract class AbstractProcessorManager<ElementType extends EObject>
* Initialize the map of processors indexed by their id.
*/
@Init
public
final
void
initializeProcessorsByID
()
{
public
final
void
initializeProcessorsByID
()
{
this
.
processorsByID
=
new
HashMap
<
String
,
Processor
<
ElementType
>>();
for
(
Processor
<
ElementType
>
processor
:
this
.
processors
)
{
this
.
processorsByID
.
put
(
processor
.
getProcessorID
(),
processor
);
...
...
frascati/modules/frascati-assembly-factory/src/main/java/org/ow2/frascati/assembly/factory/processor/ScaPropertyTypeXsdProcessor.java
View file @
a3852172
...
...
@@ -120,7 +120,7 @@ public class ScaPropertyTypeXsdProcessor
/**
* Map of the XSD datatypes.
*/
p
rotected
static
final
Map
<
String
,
XsdType
>
VALUES
=
new
HashMap
<
String
,
XsdType
>();
p
ublic
static
final
Map
<
String
,
XsdType
>
VALUES
=
new
HashMap
<
String
,
XsdType
>();
static
{
VALUES
.
put
(
ANYSIMPLETYPE
.
getLabel
(),
ANYSIMPLETYPE
);
VALUES
.
put
(
ANYURI
.
getLabel
(),
ANYURI
);
...
...
frascati/modules/frascati-binding-jms/tests/src/main/java/org/ow2/frascati/examples/jms/sender/Node.java
View file @
a3852172
...
...
@@ -36,26 +36,28 @@ import org.osoa.sca.annotations.Reference;
* @author Philippe Merle.
*/
@Service
(
interfaces
={
Runnable
.
class
,
Sender
.
class
})
public
class
Node
implements
Runnable
,
Sender
{
public
final
void
run
()
{
System
.
out
.
println
(
"Node(name="
+
componentName
+
") run()..."
);
public
class
Node
implements
Runnable
,
Sender
{
public
final
void
run
()
{
log
(
"run()..."
);
if
(
out
!=
null
)
{
Message
msg
=
new
Message
();
msg
.
setFrom
(
componentName
);
msg
.
setTo
(
"all"
);
msg
.
setTitle
(
"HelloWorld"
);
msg
.
setBody
(
"Best Regards."
);
System
.
out
.
println
(
"Node(name="
+
componentName
+
")
send "
+
toString
(
msg
)
+
"..."
);
log
(
"
send "
+
toString
(
msg
)
+
"..."
);
out
.
send
(
msg
);
}
}
public
final
void
send
(
Message
msg
)
{
System
.
out
.
println
(
"Node(name="
+
componentName
+
")
receive "
+
toString
(
msg
));
log
(
"
receive "
+
toString
(
msg
));
if
(
out
!=
null
)
{
msg
.
setFrom
(
componentName
);
System
.
out
.
println
(
"Node(name="
+
componentName
+
")
send "
+
toString
(
msg
));
log
(
"
send "
+
toString
(
msg
));
out
.
send
(
msg
);
}
}
...
...
@@ -79,4 +81,9 @@ public class Node implements Runnable, Sender {
sb
.
append
(
"')"
);
return
sb
.
toString
();
}
private
void
log
(
String
message
)
{
System
.
out
.
println
(
"Node(name="
+
componentName
+
") "
+
message
);
}
}
frascati/modules/frascati-component-factory/src/main/java/org/ow2/frascati/component/factory/impl/ComponentFactoryImpl.java
View file @
a3852172
...
...
@@ -131,6 +131,7 @@ public class ComponentFactoryImpl
String
membraneDescription
=
membraneProvider
.
getMembraneDescription
();
Component
fractalBootstrapComponent
;
String
msg
=
"create the "
+
membraneDescription
+
" bootstrap component"
;
try
{
Class
<?>
membraneClass
=
membraneProvider
.
getMembraneClass
();
HashMap
<
String
,
Object
>
hints
=
new
HashMap
<
String
,
Object
>();
...
...
@@ -139,11 +140,11 @@ public class ComponentFactoryImpl
// to load Fractal bootstrap classes instead of the class loader
// where Fractal API was loaded.
hints
.
put
(
"classloader"
,
Thread
.
currentThread
().
getContextClassLoader
());
logDo
(
"create the "
+
membraneDescription
+
" bootstrap component"
);
logDo
(
msg
);
fractalBootstrapComponent
=
Fractal
.
getBootstrapComponent
(
hints
);
logDone
(
"create the "
+
membraneDescription
+
" bootstrap component"
);
logDone
(
msg
);
}
catch
(
InstantiationException
ie
)
{
severe
(
new
FactoryException
(
"Can't
create the "
+
membraneDescription
+
" bootstrap component"
,
ie
));
severe
(
new
FactoryException
(
"Can't
"
+
msg
,
ie
));
return
;
}
...
...
@@ -201,9 +202,10 @@ public class ComponentFactoryImpl
/**
* @see ComponentFactory#generateScaCompositeMembrane(ComponentType)
*/
public
final
void
generateScaCompositeMembrane
(
ComponentType
c
omponentType
)
public
final
void
generateScaCompositeMembrane
(
ComponentType
c
t
)
throws
FactoryException
{
ComponentType
componentType
=
ct
;
if
(
componentType
==
null
)
{
componentType
=
createComponentType
(
new
InterfaceType
[
0
]);
}
...
...
@@ -252,9 +254,10 @@ public class ComponentFactoryImpl
/**
* @see ComponentFactory#createScaCompositeComponent(ComponentType)
*/
public
final
Component
createScaCompositeComponent
(
ComponentType
c
omponentType
)
public
final
Component
createScaCompositeComponent
(
ComponentType
c
t
)
throws
FactoryException
{
ComponentType
componentType
=
ct
;
if
(
componentType
==
null
)
{
componentType
=
createComponentType
(
new
InterfaceType
[
0
]);
}
...
...
frascati/modules/frascati-implementation-bpel/src/main/java/org/ow2/frascati/implementation/bpel/easybpel/EasyBpelContextImpl.java
View file @
a3852172
...
...
@@ -67,15 +67,12 @@ implements ExternalContext
* Wait the BPEL reply message.
*/
protected
final
synchronized
BPELInternalMessage
waitReply
()
throws
InterruptedException
{
if
(
this
.
reply
==
null
)
{
try
{
this
.
wait
();
}
catch
(
InterruptedException
ie
)
{
// TODO: Is there something to do???
}
}
return
this
.
reply
;
while
(
this
.
reply
==
null
)
{
this
.
wait
();
}
return
this
.
reply
;
}