Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Instrument Control
NomadCommandSystem
Commits
d2eb47b6
Commit
d2eb47b6
authored
Mar 06, 2017
by
yannick legoc
Browse files
Removed last corba stuff.
parent
d19bb2d4
Changes
8
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
d2eb47b6
...
...
@@ -76,11 +76,6 @@
<artifactId>
avalon-framework-impl
</artifactId>
<version>
4.2.0
</version>
</dependency>
<dependency>
<groupId>
org.jacorb
</groupId>
<artifactId>
jacorb
</artifactId>
<version>
3.7
</version>
</dependency>
<dependency>
<groupId>
logkit
</groupId>
<artifactId>
logkit
</artifactId>
...
...
src/main/java/fr/ill/ics/bridge/LoginManager.java
View file @
d2eb47b6
...
...
@@ -20,8 +20,6 @@ package fr.ill.ics.bridge;
import
java.util.Properties
;
import
fr.ill.ics.nscclient.corbabase.CorbaNamingService
;
import
fr.ill.ics.nscclient.corbabase.CorbaORB
;
import
fr.ill.ics.nscclient.servant.ConfigurationManager.LoadFailure
;
import
fr.ill.ics.nscclient.serverconnection.ServerConnection
;
import
fr.ill.ics.nscclient.sessionmanagement.ServerSessionManager
;
...
...
@@ -45,23 +43,6 @@ public class LoginManager {
public
class
ClientAlreadyLaunchedException
extends
Exception
{}
public
class
ConnectionFailure
extends
Exception
{};
public
void
initCommunication
()
throws
ConnectionFailure
{
initCommunication
(
null
);
}
/*
* Example of jacorb properties:
* Properties jacorbProperties = new Properties();
* ...
* jacorbProperties.setProperty("ORBInitRef.NameService", "corbaloc::localhost:2809/NameService");
*/
public
void
initCommunication
(
Properties
jacorbProperties
)
throws
ConnectionFailure
{
CorbaORB
.
getInstance
().
init
(
jacorbProperties
);
CorbaNamingService
.
getInstance
().
init
();
if
(!
CorbaNamingService
.
getInstance
().
isOk
())
{
throw
new
ConnectionFailure
();
}
}
public
void
login
(
String
login
,
String
password
,
boolean
standalone
,
String
serverId
)
throws
LoginIncorrectException
,
ClientAlreadyLaunchedException
,
ConnectionFailure
{
try
{
...
...
src/main/java/fr/ill/ics/bridge/ResourceManager.java
View file @
d2eb47b6
...
...
@@ -19,13 +19,14 @@
package
fr.ill.ics.bridge
;
import
fr.ill.ics.nscclient.
servant.CorbaResourceManage
r
;
import
fr.ill.ics.nscclient.
dataprovider.ServantManagerAccesso
r
;
import
fr.ill.ics.nscclient.servant.ResourceNotFoundException
;
public
abstract
class
ResourceManager
{
public
class
ResourceManager
{
private
String
serverId
;
private
static
ResourceManager
instance
=
null
;
public
static
ResourceManager
getInstance
()
{
...
...
@@ -33,7 +34,7 @@ public abstract class ResourceManager {
}
public
static
void
initInstance
(
String
serverId
)
{
instance
=
new
Corba
ResourceManager
(
serverId
);
instance
=
new
ResourceManager
(
serverId
);
instance
.
init
();
}
...
...
@@ -41,9 +42,66 @@ public abstract class ResourceManager {
instance
=
null
;
}
protected
abstract
void
init
();
public
abstract
String
[]
getResourceFilesByExtension
(
String
extension
);
public
abstract
byte
[]
getBinaryFileContent
(
String
controllerType
,
String
fileName
)
throws
ResourceNotFoundException
;
public
abstract
String
getFileContent
(
String
controllerType
,
String
fileName
)
throws
ResourceNotFoundException
;
public
abstract
void
setFileContent
(
String
controllerType
,
String
fileName
,
String
content
);
private
ResourceManager
(
String
serverId
)
{
this
.
serverId
=
serverId
;
}
protected
void
init
()
{
}
public
String
[]
getResourceFilesByExtension
(
String
extension
)
{
return
ServantManagerAccessor
.
getInstance
(
serverId
).
getResourceFilesByExtension
(
extension
);
}
public
byte
[]
getBinaryFileContent
(
String
controllerType
,
String
fileName
)
throws
ResourceNotFoundException
{
return
ServantManagerAccessor
.
getInstance
(
serverId
).
readBinaryResourceFile
(
controllerType
,
fileName
);
}
public
String
getFileContent
(
String
controllerType
,
String
fileName
)
throws
ResourceNotFoundException
{
return
ServantManagerAccessor
.
getInstance
(
serverId
).
readResourceFile
(
controllerType
,
fileName
);
/*
String fullFilePath = "/home/dpt/ortizh/tmp/" + fileName;
if (new File(fullFilePath).exists()) {
try {
String content = "";
String line;
BufferedReader in = new BufferedReader(new FileReader(fullFilePath));
while ((line = in.readLine()) != null) {
content = content + line + "\n";
}
in.close();
return content;
} catch (IOException e) {
System.err.println("IOException while getting content of file " + fullFilePath);
e.printStackTrace();
}
} else {
throw new ResourceNotFoundException(fileName);
}
return null;
*/
}
public
void
setFileContent
(
String
controllerType
,
String
fileName
,
String
content
)
{
System
.
out
.
println
(
"H.ORTIZ: call to writeResourceFile commented .................................................."
+
fileName
);
//ServantManagerAccessor.getInstance(serverId).writeResourceFile(controllerType, fileName, content);
/*
String fullFilePath = "/home/dpt/ortizh/tmp/" + fileName;
if (!new File(fullFilePath).exists()) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(fullFilePath));
out.write(content);
out.close();
} catch (IOException e) {
System.err.println("IOException while setting content of file " + fullFilePath);
e.printStackTrace();
}
}
*/
}
}
src/main/java/fr/ill/ics/nscclient/corbabase/CorbaNamingService.java
deleted
100644 → 0
View file @
d19bb2d4
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package
fr.ill.ics.nscclient.corbabase
;
import
org.omg.CosNaming.NameComponent
;
import
org.omg.CosNaming.NamingContextPackage.AlreadyBound
;
import
org.omg.CosNaming.NamingContextPackage.CannotProceed
;
import
org.omg.CosNaming.NamingContextPackage.InvalidName
;
import
org.omg.CosNaming.NamingContextPackage.NotFound
;
public
class
CorbaNamingService
{
public
class
CORBAResolveFailureException
extends
Exception
{}
public
class
CORBANameServiceFailureException
extends
Exception
{}
static
private
CorbaNamingService
instance
=
null
;
private
org
.
omg
.
CosNaming
.
NamingContextExt
rootContext
;
private
org
.
omg
.
CosNaming
.
NamingContextExt
clientContext
;
static
boolean
allOk
=
false
;
// private constructor
private
CorbaNamingService
()
{
}
static
public
CorbaNamingService
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
CorbaNamingService
();
}
return
instance
;
}
public
void
init
()
{
allOk
=
true
;
try
{
org
.
omg
.
CORBA
.
Object
nco
=
CorbaORB
.
getInstance
().
resolve
(
"NameService"
);
rootContext
=
org
.
omg
.
CosNaming
.
NamingContextExtHelper
.
narrow
(
nco
);
}
catch
(
CorbaORB
.
CORBAInvalidNameException
ie
)
{
// System.err.println("Invalid name for Naming Service");
allOk
=
false
;
}
catch
(
CorbaORB
.
CORBAException
ce
)
{
// System.err.println("Cannot narrow reference for Naming Context Object");
allOk
=
false
;
}
catch
(
org
.
omg
.
CORBA
.
SystemException
e
)
{
// System.err.println("Cannot narrow reference for Naming Context Object");
allOk
=
false
;
}
}
public
boolean
isOk
()
{
return
allOk
;
}
public
org
.
omg
.
CORBA
.
Object
resolveObject
(
String
contextName1
,
String
contextName2
,
String
objectName
)
throws
CORBAResolveFailureException
{
NameComponent
[]
nc
=
new
NameComponent
[
3
];
nc
[
0
]
=
new
NameComponent
(
contextName1
,
""
);
nc
[
1
]
=
new
NameComponent
(
contextName2
,
""
);
nc
[
2
]
=
new
NameComponent
(
objectName
,
""
);
try
{
return
rootContext
.
resolve
(
nc
);
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
NotFound
nf
)
{
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
CannotProceed
cp
)
{
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
InvalidName
in
)
{
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CORBA
.
SystemException
e
)
{
throw
new
CORBAResolveFailureException
();
}
}
public
org
.
omg
.
CORBA
.
Object
resolveObject
(
String
contextName
,
String
objectName
)
throws
CORBAResolveFailureException
{
NameComponent
[]
nc
=
new
NameComponent
[
2
];
nc
[
0
]
=
new
NameComponent
(
contextName
,
""
);
nc
[
1
]
=
new
NameComponent
(
objectName
,
""
);
try
{
return
rootContext
.
resolve
(
nc
);
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
NotFound
nf
)
{
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
CannotProceed
cp
)
{
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
InvalidName
in
)
{
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CORBA
.
SystemException
e
)
{
throw
new
CORBAResolveFailureException
();
}
}
public
org
.
omg
.
CORBA
.
Object
resolveObject
(
String
objectName
)
throws
CORBAResolveFailureException
{
NameComponent
[]
nc
=
new
NameComponent
[
1
];
nc
[
0
]
=
new
NameComponent
(
objectName
,
""
);
try
{
return
rootContext
.
resolve
(
nc
);
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
NotFound
nf
)
{
// System.err.println("CorbaClientNS: Unable to find "+objectName);
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
CannotProceed
cp
)
{
// System.err.println("CorbaClientNS: Cannot proceed");
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
InvalidName
in
)
{
// System.err.println("CorbaClientNS: InvalidName when resolving "
// +objectName);
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CORBA
.
SystemException
e
)
{
// System.err.println("CorbaClientNS: General CORBA exception");
throw
new
CORBAResolveFailureException
();
}
}
public
org
.
omg
.
CORBA
.
Object
resolveObjectWithKind
(
String
objectName
,
String
kindName
)
throws
CORBAResolveFailureException
{
NameComponent
[]
nc
=
new
NameComponent
[
1
];
nc
[
0
]
=
new
NameComponent
(
objectName
,
kindName
);
try
{
return
rootContext
.
resolve
(
nc
);
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
NotFound
nf
)
{
// System.err.println("CorbaClientNS: Unable to find "+objectName);
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
CannotProceed
cp
)
{
// System.err.println("CorbaClientNS: Cannot proceed");
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CosNaming
.
NamingContextPackage
.
InvalidName
in
)
{
// System.err.println("CorbaClientNS: InvalidName when resolving "
// +objectName);
throw
new
CORBAResolveFailureException
();
}
catch
(
org
.
omg
.
CORBA
.
SystemException
e
)
{
// System.err.println("CorbaClientNS: General CORBA exception");
throw
new
CORBAResolveFailureException
();
}
}
public
boolean
createContext
(
String
contextName
)
{
boolean
success
=
false
;
/*
* Create a context - fairly simple method - we don't have anything too
* complex/
*/
NameComponent
[]
nc
=
new
NameComponent
[
1
];
nc
[
0
]
=
new
NameComponent
(
contextName
,
""
);
removeContext
(
contextName
);
try
{
clientContext
=
org
.
omg
.
CosNaming
.
NamingContextExtHelper
.
narrow
(
rootContext
.
bind_new_context
(
nc
));
success
=
true
;
}
catch
(
NotFound
e
)
{
e
.
printStackTrace
();
}
catch
(
AlreadyBound
e
)
{
e
.
printStackTrace
();
}
catch
(
CannotProceed
e
)
{
e
.
printStackTrace
();
}
catch
(
InvalidName
e
)
{
e
.
printStackTrace
();
}
return
success
;
}
public
void
removeContext
(
String
contextName
)
{
/*
* remove a context - again, we're assuming that this is attached
* directly to the root context.
*/
NameComponent
[]
nc
=
new
NameComponent
[
1
];
nc
[
0
]
=
new
NameComponent
(
contextName
,
""
);
try
{
rootContext
.
unbind
(
nc
);
}
catch
(
NotFound
e
)
{
}
catch
(
CannotProceed
e
)
{
}
catch
(
InvalidName
e
)
{
}
}
public
boolean
bindObject
(
String
objectName
,
org
.
omg
.
CORBA
.
Object
obj
)
{
boolean
success
=
false
;
/*
* Create name
*/
NameComponent
[]
name
=
new
NameComponent
[
1
];
name
[
0
]
=
new
NameComponent
(
objectName
,
""
);
/*
* Bind the object. Not ok to do rebind - should through exception if it
* exists already - we need to shut down properly.
*/
try
{
clientContext
.
bind
(
name
,
obj
);
success
=
true
;
}
catch
(
NotFound
e
)
{
e
.
printStackTrace
();
}
catch
(
CannotProceed
e
)
{
e
.
printStackTrace
();
}
catch
(
InvalidName
e
)
{
e
.
printStackTrace
();
}
catch
(
AlreadyBound
e
)
{
e
.
printStackTrace
();
}
return
success
;
}
public
boolean
unbindObject
(
String
objectName
)
{
boolean
success
=
false
;
/*
* Create name
*/
NameComponent
[]
name
=
new
NameComponent
[
0
];
name
[
0
]
=
new
NameComponent
(
objectName
,
""
);
/*
* Bind the object. Not ok to do rebind - should through exception if it
* exists already - we need to shut down properly.
*/
try
{
clientContext
.
unbind
(
name
);
success
=
true
;
}
catch
(
NotFound
e
)
{
e
.
printStackTrace
();
}
catch
(
CannotProceed
e
)
{
e
.
printStackTrace
();
}
catch
(
InvalidName
e
)
{
e
.
printStackTrace
();
}
return
success
;
}
}
\ No newline at end of file
src/main/java/fr/ill/ics/nscclient/corbabase/CorbaORB.java
deleted
100644 → 0
View file @
d19bb2d4
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package
fr.ill.ics.nscclient.corbabase
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
import
org.omg.CORBA.ORB
;
import
org.omg.CORBA.Policy
;
import
org.omg.PortableServer.LifespanPolicyValue
;
import
org.omg.PortableServer.POA
;
import
org.omg.PortableServer.POAHelper
;
import
org.omg.PortableServer.POAManagerPackage.AdapterInactive
;
import
fr.ill.ics.util.ConfigManager
;
public
class
CorbaORB
{
public
class
CORBAInvalidNameException
extends
Exception
{}
public
class
CORBAException
extends
Exception
{}
static
private
CorbaORB
instance
=
null
;
private
ORB
orb
;
private
POA
rootPOA
;
private
CorbaORB
()
{
}
private
static
String
getNameServiceFromNomadServerEndpoint
(
String
endpoint
)
{
String
prefix
=
"tcp://"
;
if
(!
endpoint
.
startsWith
(
prefix
))
{
return
null
;
}
int
index
=
endpoint
.
lastIndexOf
(
':'
);
if
(
index
==
-
1
)
{
return
null
;
}
return
endpoint
.
substring
(
6
,
index
);
}
/*
* Example of jacorb properties:
* Properties jacorbProperties = new Properties();
* ...
* jacorbProperties.setProperty("ORBInitRef.NameService", "corbaloc::localhost:2809/NameService");
*/
public
void
init
(
Properties
jacorbProperties
)
{
// Loading the file jacorb.properties if jacorbProperties is null
if
(
jacorbProperties
==
null
)
{
InputStream
stream
=
CorbaORB
.
class
.
getClassLoader
().
getResourceAsStream
(
"jacorb.properties"
);
jacorbProperties
=
new
Properties
();
try
{
jacorbProperties
.
load
(
stream
);
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Unable to load jacorb.properties"
);
}
}
String
nomadServerEndpoint
=
ConfigManager
.
getInstance
().
getNomadServerEndpoint
();
String
nomadServerHostname
=
getNameServiceFromNomadServerEndpoint
(
nomadServerEndpoint
);
jacorbProperties
.
setProperty
(
"ORBInitRef.NameService"
,
"corbaloc::"
+
nomadServerHostname
+
":2809/NameService"
);
try
{
// dummy args
String
[]
args
=
{
""
};
// Initialise the ORB
orb
=
ORB
.
init
(
args
,
jacorbProperties
);
// Get Reference to Root POA
org
.
omg
.
CORBA
.
Object
obj
=
resolve
(
"RootPOA"
);
rootPOA
=
POAHelper
.
narrow
(
obj
);
// Activate the POAManager
rootPOA
.
the_POAManager
().
activate
();
Policy
[]
policies
=
{
rootPOA
.
create_lifespan_policy
(
LifespanPolicyValue
.
PERSISTENT
),
};
}
catch
(
org
.
omg
.
CORBA
.
SystemException
e
)
{
System
.
err
.
println
(
"SystemException: Unable to initialise ORB"
);
}
catch
(
CORBAInvalidNameException
e
)
{
System
.
err
.
println
(
"CORBAInvalidNameException: Unable to find Root POA"
);
}
catch
(
CORBAException
e
)
{
System
.
err
.
println
(
"CORBAException: Unable to initialise ORB"
);
}
catch
(
AdapterInactive
e
)
{
e
.
printStackTrace
();
}
}
static
public
CorbaORB
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
CorbaORB
();
}
return
instance
;
}
public
org
.
omg
.
CORBA
.
Object
resolve
(
String
name
)
throws
CORBAInvalidNameException
,
CORBAException
{
org
.
omg
.
CORBA
.
Object
nco
;
try
{
nco
=
orb
.
resolve_initial_references
(
name
);
}
catch
(
org
.
omg
.
CORBA
.
ORBPackage
.
InvalidName
in
)
{
throw
new
CORBAInvalidNameException
();
}
catch
(
org
.
omg
.
CORBA
.
SystemException
se
)
{
throw
new
CORBAException
();
}
return
nco
;
}
public
org
.
omg
.
PortableServer
.
POA
getPOA
()
{
return
rootPOA
;
}
public
void
run
()
{
//Accept requests (blocking call)
orb
.
run
();
// Shutdown the orb
orb
.
destroy
();
}
}
\ No newline at end of file
src/main/java/fr/ill/ics/nscclient/dataprovider/ServantManagerAccessor.java
View file @
d2eb47b6
...
...
@@ -51,7 +51,7 @@ import fr.ill.ics.nscclient.servant.ResourceNotFoundException;
import
fr.ill.ics.nscclient.servant.Servant
;
import
fr.ill.ics.nscclient.servant.SpyPropertyDescriptor
;
import
fr.ill.ics.nscclient.servant.StandardPropertyDescriptor
;
import
fr.ill.ics.nscclient.servant.scan.
Corba
IcsParameterizableScan1D
;
import
fr.ill.ics.nscclient.servant.scan.IcsParameterizableScan1D
;
import
fr.ill.ics.nscclient.serverconnection.ServerInstance
;
public
class
ServantManagerAccessor
{
...
...
@@ -541,7 +541,7 @@ public class ServantManagerAccessor {
ControllerServant
controller
=
null
;
if
(
descriptor
.
getType
().
equals
(
PARAMETERIZABLE_SCAN_1D
))
{
controller
=
new
Corba
IcsParameterizableScan1D
(
DATABASE_ID
,
descriptor
.
getId
(),
descriptor
);
controller
=
new
IcsParameterizableScan1D
(
DATABASE_ID
,
descriptor
.
getId
(),
descriptor
);
}
else
{
controller
=
new
ControllerServant
(
DATABASE_ID
,
descriptor
.
getId
(),
descriptor
);
}
...
...
src/main/java/fr/ill/ics/nscclient/servant/CorbaResourceManager.java
deleted
100644 → 0
View file @
d19bb2d4