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
joram
joram
Commits
a2861e6a
Commit
a2861e6a
authored
Jun 22, 2010
by
Nicolas Tachker
Browse files
maven migration.
parent
5a520577
Changes
90
Expand all
Hide whitespace changes
Inline
Side-by-side
joram/jndi/client/pom.xml
0 → 100644
View file @
a2861e6a
<?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/maven-v4_0_0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.objectweb.joram
</groupId>
<artifactId>
jndi-client
</artifactId>
<packaging>
bundle
</packaging>
<name>
JORAM :: jndi :: client
</name>
<description>
Builds the Joram jndi client project.
</description>
<parent>
<groupId>
org.objectweb.joram
</groupId>
<artifactId>
jndi
</artifactId>
<version>
5.3.2.53-SNAPSHOT
</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>
org.apache.felix
</groupId>
<artifactId>
maven-bundle-plugin
</artifactId>
<extensions>
true
</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
${pom.artifactId}
</Bundle-SymbolicName>
<Export-Package>
fr.dyade.aaa.jndi2.client,
fr.dyade.aaa.jndi2.haclient,
fr.dyade.aaa.jndi2.hascn,
fr.dyade.aaa.jndi2.scn
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>
org.objectweb.joram
</groupId>
<artifactId>
jndi-shared
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
joram/jndi/client/src/main/java/fr/dyade/aaa/jndi2/client/NamingConnection.java
0 → 100644
View file @
a2861e6a
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2004 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): ScalAgent Distributed Technologies
*/
package
fr.dyade.aaa.jndi2.client
;
import
java.util.*
;
import
javax.naming.*
;
import
fr.dyade.aaa.jndi2.msg.*
;
public
interface
NamingConnection
{
public
JndiReply
invoke
(
JndiRequest
request
)
throws
NamingException
;
public
NamingConnection
cloneConnection
();
public
Hashtable
getEnvironment
()
throws
NamingException
;
}
joram/jndi/client/src/main/java/fr/dyade/aaa/jndi2/client/NamingContextFactory.java
0 → 100644
View file @
a2861e6a
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2007 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Sofiane Chibani
* Contributor(s): ScalAgent Distributed Technologies
*/
package
fr.dyade.aaa.jndi2.client
;
import
java.util.Hashtable
;
import
java.util.StringTokenizer
;
import
javax.naming.CompositeName
;
import
javax.naming.Context
;
import
javax.naming.NamingException
;
import
javax.naming.spi.InitialContextFactory
;
import
org.objectweb.util.monolog.api.BasicLevel
;
public
class
NamingContextFactory
implements
InitialContextFactory
{
/**
* Name of the property which defines the listener port used when
* creating an initial context using this factory.
*/
public
final
static
String
JAVA_PORT_PROPERTY
=
"java.naming.factory.port"
;
/**
* Name of the property which defines the host name used when
* creating an initial context using this factory.
*/
public
final
static
String
JAVA_HOST_PROPERTY
=
"java.naming.factory.host"
;
/**
* Specific property. It is useful when several naming provider use
* the same property.
*/
public
final
static
String
SCN_PORT_PROPERTY
=
"scn.naming.factory.port"
;
/**
* Specific property. It is useful when several naming provider use
* the same property.
*/
public
final
static
String
SCN_HOST_PROPERTY
=
"scn.naming.factory.host"
;
/**
* Specific property. It is useful when several naming provider use
* the same property.
*/
public
final
static
String
SCN_PROVIDER_URL
=
"scn.naming.provider.url"
;
/**
* @param env This contains the hostname and the port.
* @return A JNDI initial context.
* @exception NamingException Thrown if the host and port properties
* aren't strings, if the port string does not represent a valid number,
* or if an exception is thrown from the NamingContext constructor.
*/
public
Context
getInitialContext
(
Hashtable
env
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextFactory.getInitialContext("
+
env
+
')'
);
return
new
NamingContextImpl
(
getNamingConnection
(
env
),
new
CompositeName
());
}
public
static
NamingConnection
getNamingConnection
(
Hashtable
env
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextFactory.getNamingConnection("
+
env
+
')'
);
try
{
String
host
;
int
port
;
// The URL format is scn://host:port
String
url
=
(
String
)
env
.
get
(
SCN_PROVIDER_URL
);
if
(
url
==
null
)
url
=
(
String
)
env
.
get
(
Context
.
PROVIDER_URL
);
if
(
url
!=
null
&&
!
url
.
equals
(
""
))
{
StringTokenizer
tokenizer
=
new
StringTokenizer
(
url
,
"/:,"
);
if
(!
tokenizer
.
hasMoreElements
())
throw
new
NamingException
(
"URL not valid:"
+
url
);
String
protocol
=
tokenizer
.
nextToken
();
if
(
protocol
.
equals
(
"scn"
))
{
host
=
tokenizer
.
nextToken
();
String
portStr
=
tokenizer
.
nextToken
();
port
=
Integer
.
parseInt
(
portStr
);
}
else
{
throw
new
NamingException
(
"Unknown protocol:"
+
protocol
);
}
}
else
{
host
=
(
String
)
env
.
get
(
SCN_HOST_PROPERTY
);
if
(
host
==
null
)
host
=
System
.
getProperty
(
SCN_HOST_PROPERTY
);
if
(
host
==
null
)
host
=
(
String
)
env
.
get
(
JAVA_HOST_PROPERTY
);
if
(
host
==
null
)
host
=
System
.
getProperty
(
JAVA_HOST_PROPERTY
);
if
(
host
==
null
)
host
=
"localhost"
;
String
portStr
=
(
String
)
env
.
get
(
SCN_PORT_PROPERTY
);
if
(
portStr
==
null
)
portStr
=
System
.
getProperty
(
SCN_PORT_PROPERTY
);
if
(
portStr
==
null
)
portStr
=
(
String
)
env
.
get
(
JAVA_PORT_PROPERTY
);
if
(
portStr
==
null
)
portStr
=
System
.
getProperty
(
JAVA_PORT_PROPERTY
);
if
(
portStr
==
null
)
portStr
=
"16400"
;
port
=
Integer
.
parseInt
(
portStr
);
}
SimpleNamingConnection
namingConnection
=
new
SimpleNamingConnection
(
host
,
port
,
env
);
namingConnection
.
init
(
host
,
port
,
env
);
return
namingConnection
;
}
catch
(
NumberFormatException
e
)
{
NamingException
nx
=
new
NamingException
();
nx
.
setRootCause
(
e
);
throw
nx
;
}
catch
(
Exception
e
)
{
NamingException
nx
=
new
NamingException
();
nx
.
setRootCause
(
e
);
throw
nx
;
}
}
}
joram/jndi/client/src/main/java/fr/dyade/aaa/jndi2/client/NamingContextImpl.java
0 → 100644
View file @
a2861e6a
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Sofiane Chibani
* Contributor(s): David Feliot, Nicolas Tachker, Frederic Maistre
*/
package
fr.dyade.aaa.jndi2.client
;
import
java.util.Hashtable
;
import
javax.naming.Binding
;
import
javax.naming.CompositeName
;
import
javax.naming.Context
;
import
javax.naming.InvalidNameException
;
import
javax.naming.Name
;
import
javax.naming.NameParser
;
import
javax.naming.NamingEnumeration
;
import
javax.naming.NamingException
;
import
javax.naming.Referenceable
;
import
org.objectweb.util.monolog.api.BasicLevel
;
import
fr.dyade.aaa.jndi2.msg.BindRequest
;
import
fr.dyade.aaa.jndi2.msg.CreateSubcontextRequest
;
import
fr.dyade.aaa.jndi2.msg.DestroySubcontextRequest
;
import
fr.dyade.aaa.jndi2.msg.JndiError
;
import
fr.dyade.aaa.jndi2.msg.JndiReply
;
import
fr.dyade.aaa.jndi2.msg.ListBindingsReply
;
import
fr.dyade.aaa.jndi2.msg.ListBindingsRequest
;
import
fr.dyade.aaa.jndi2.msg.ListReply
;
import
fr.dyade.aaa.jndi2.msg.ListRequest
;
import
fr.dyade.aaa.jndi2.msg.LookupReply
;
import
fr.dyade.aaa.jndi2.msg.LookupRequest
;
import
fr.dyade.aaa.jndi2.msg.UnbindRequest
;
public
class
NamingContextImpl
implements
Context
{
private
NamingConnection
connection
;
private
CompositeName
contextPath
;
public
NamingContextImpl
(
NamingConnection
connection
,
CompositeName
contextPath
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.<init>("
+
connection
+
','
+
contextPath
+
')'
);
this
.
connection
=
connection
;
this
.
contextPath
=
contextPath
;
}
/** Empty constructor, called by the subclass. */
protected
NamingContextImpl
()
{
contextPath
=
new
CompositeName
();
}
public
void
bind
(
Name
name
,
Object
obj
)
throws
NamingException
{
bind
(
name
.
toString
(),
obj
);
}
public
void
bind
(
String
name
,
Object
obj
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.bind("
+
name
+
','
+
obj
+
')'
);
if
(
obj
instanceof
Referenceable
)
{
obj
=
((
Referenceable
)
obj
).
getReference
();
}
JndiReply
reply
=
connection
.
invoke
(
new
BindRequest
(
merge
(
contextPath
,
name
),
obj
));
if
(
reply
instanceof
JndiError
)
{
NamingException
exc
=
((
JndiError
)
reply
).
getException
();
exc
.
fillInStackTrace
();
throw
exc
;
}
}
public
void
rebind
(
Name
name
,
Object
obj
)
throws
NamingException
{
rebind
(
name
.
toString
(),
obj
);
}
public
void
rebind
(
String
name
,
Object
obj
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.rebind("
+
name
+
','
+
obj
+
')'
);
if
(
obj
instanceof
Referenceable
)
{
obj
=
((
Referenceable
)
obj
).
getReference
();
}
JndiReply
reply
=
connection
.
invoke
(
new
BindRequest
(
merge
(
contextPath
,
name
),
obj
,
true
));
if
(
reply
instanceof
JndiError
)
{
NamingException
exc
=
((
JndiError
)
reply
).
getException
();
exc
.
fillInStackTrace
();
throw
exc
;
}
}
public
Object
lookup
(
Name
name
)
throws
NamingException
{
return
lookup
(
name
.
toString
());
}
public
Object
lookup
(
String
name
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.lookup("
+
name
+
')'
);
CompositeName
path
=
merge
(
contextPath
,
name
);
JndiReply
reply
=
connection
.
invoke
(
new
LookupRequest
(
path
));
if
(
reply
instanceof
JndiError
)
{
NamingException
exc
=
((
JndiError
)
reply
).
getException
();
exc
.
fillInStackTrace
();
throw
exc
;
}
else
if
(
reply
instanceof
LookupReply
)
{
Object
obj
=
((
LookupReply
)
reply
).
getObject
();
return
obj
;
}
else
{
return
new
NamingContextImpl
(
connection
.
cloneConnection
(),
path
);
}
}
public
void
unbind
(
Name
name
)
throws
NamingException
{
unbind
(
name
.
toString
());
}
public
void
unbind
(
String
name
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.unbind("
+
name
+
')'
);
JndiReply
reply
=
connection
.
invoke
(
new
UnbindRequest
(
merge
(
contextPath
,
name
)));
if
(
reply
instanceof
JndiError
)
{
NamingException
exc
=
((
JndiError
)
reply
).
getException
();
exc
.
fillInStackTrace
();
throw
exc
;
}
}
public
void
close
()
throws
NamingException
{}
protected
void
finalize
()
throws
Throwable
{
close
();
}
public
Hashtable
getEnvironment
()
throws
NamingException
{
return
connection
.
getEnvironment
();
}
public
NamingEnumeration
list
(
Name
name
)
throws
NamingException
{
return
list
(
name
.
toString
());
}
public
NamingEnumeration
list
(
String
name
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.list("
+
name
+
')'
);
JndiReply
reply
=
connection
.
invoke
(
new
ListRequest
(
merge
(
contextPath
,
name
)));
if
(
reply
instanceof
JndiError
)
{
NamingException
exc
=
((
JndiError
)
reply
).
getException
();
exc
.
fillInStackTrace
();
throw
exc
;
}
else
{
return
((
ListReply
)
reply
).
getEnumeration
();
}
}
public
NamingEnumeration
listBindings
(
Name
name
)
throws
NamingException
{
return
listBindings
(
name
.
toString
());
}
public
NamingEnumeration
listBindings
(
String
name
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.listBindings("
+
name
+
')'
);
CompositeName
queryPath
=
merge
(
contextPath
,
name
);
JndiReply
reply
=
connection
.
invoke
(
new
ListBindingsRequest
(
queryPath
));
if
(
reply
instanceof
JndiError
)
{
NamingException
exc
=
((
JndiError
)
reply
).
getException
();
exc
.
fillInStackTrace
();
throw
exc
;
}
else
{
ListBindingsReply
lbr
=
(
ListBindingsReply
)
reply
;
// 1- resolve contexts
Binding
[]
bindings
=
lbr
.
getContexts
();
for
(
int
i
=
0
;
i
<
bindings
.
length
;
i
++)
{
CompositeName
subCtxPath
=
(
CompositeName
)
queryPath
.
clone
();
subCtxPath
.
add
(
bindings
[
i
].
getName
());
bindings
[
i
].
setObject
(
new
NamingContextImpl
(
connection
.
cloneConnection
(),
subCtxPath
));
}
// 2- resolve references
lbr
.
resolveReferences
();
return
lbr
.
getEnumeration
();
}
}
public
Context
createSubcontext
(
Name
name
)
throws
NamingException
{
return
createSubcontext
(
name
.
toString
());
}
public
Context
createSubcontext
(
String
name
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.createSubcontext("
+
name
+
')'
);
CompositeName
path
=
merge
(
contextPath
,
name
);
JndiReply
reply
=
connection
.
invoke
(
new
CreateSubcontextRequest
(
path
));
if
(
reply
instanceof
JndiError
)
{
NamingException
exc
=
((
JndiError
)
reply
).
getException
();
exc
.
fillInStackTrace
();
throw
exc
;
}
else
{
return
new
NamingContextImpl
(
connection
.
cloneConnection
(),
path
);
}
}
public
void
destroySubcontext
(
Name
name
)
throws
NamingException
{
destroySubcontext
(
name
.
toString
());
}
public
void
destroySubcontext
(
String
name
)
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.destroySubcontext("
+
name
+
')'
);
JndiReply
reply
=
connection
.
invoke
(
new
DestroySubcontextRequest
(
merge
(
contextPath
,
name
)));
if
(
reply
instanceof
JndiError
)
{
NamingException
exc
=
((
JndiError
)
reply
).
getException
();
exc
.
fillInStackTrace
();
throw
exc
;
}
}
public
String
getNameInNamespace
()
throws
NamingException
{
if
(
Trace
.
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
Trace
.
logger
.
log
(
BasicLevel
.
DEBUG
,
"NamingContextImpl.getNameInNamespace()"
);
return
contextPath
.
toString
();
}
public
Object
addToEnvironment
(
Name
propName
,
Object
propVal
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
Object
addToEnvironment
(
String
propName
,
Object
propVal
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
Name
composeName
(
Name
name
,
Name
prefix
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
String
composeName
(
String
name
,
String
prefix
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
NameParser
getNameParser
(
Name
name
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
NameParser
getNameParser
(
String
name
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
Object
lookupLink
(
Name
name
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
Object
lookupLink
(
String
name
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
Object
removeFromEnvironment
(
String
propName
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
void
rename
(
Name
oldName
,
Name
newName
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
public
void
rename
(
String
oldName
,
String
newName
)
throws
NamingException
{
throw
(
new
NamingException
(
"Not yet available"
));
}
private
static
CompositeName
merge
(
CompositeName
path
,
String
name
)
throws
NamingException
{
if
(
name
==
null
)
throw
new
InvalidNameException
();
CompositeName
res
=
new
CompositeName
(
name
);
trim
(
res
);
for
(
int
i
=
path
.
size
()
-
1
;
i
>
-
1
;
i
--)
{
res
.
add
(
0
,
path
.
get
(
i
));
}
return
res
;
}
private
static
CompositeName
trim
(
CompositeName
name
)
throws
NamingException
{
int
i
=
0
;
while
(
i
<
name
.
size
())
{
String
s
=
(
String
)
name
.
remove
(
i
);
s
=
s
.
trim
();
if
(
s
.
length
()
>
0
)
{
name
.
add
(
i
,
s
);
i
++;
}
}
return
name
;
}
public
String
toString
()
{
return
'('
+
super
.
toString
()
+
",connection="
+
connection
+
",contextPath="
+
contextPath
+
')'
;
}
}
joram/jndi/client/src/main/java/fr/dyade/aaa/jndi2/client/SimpleNamingConnection.java
0 → 100644
View file @
a2861e6a
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2008 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.