本文整理了Java中javax.jcr.Session.getAttribute()
方法的一些代码示例,展示了Session.getAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getAttribute()
方法的具体详情如下:
包路径:javax.jcr.Session
类名称:Session
方法名:getAttribute
[英]Returns the value of the named attribute as an Object
, or null
if no attribute of the given name exists. See Session#getAttributeNames.
[中]以Object
或null
的形式返回命名属性的值(如果不存在给定名称的属性)。请参阅会话#GetAttributeName。
代码示例来源:origin: org.onehippo.cms7/hippo-repository-connector
/**
* Forwards the method call to the underlying session.
*/
public Object getAttribute(String name) {
return session.getAttribute(name);
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if attribute names returned by getAttributeNames() do not return
* null if used for getAttribute(String name)
*/
public void testGetAttributeNames() {
String names[] = session.getAttributeNames();
for (int i = 0; i < names.length; i++) {
assertNotNull("An attribute name returned by getAttributeNames() " +
"does not exist.",
session.getAttribute(names[i]));
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if getAttribute(String name) returns null if the requested attribute
* is not existing
*/
public void testGetAttributeFailure() {
String names[] = session.getAttributeNames();
StringBuffer notExistingName = new StringBuffer("X");
for (int i = 0; i < names.length; i++) {
notExistingName.append(names[i]);
}
assertNull("getAttribute(String name) must return null if the " +
"requested attribute is not existing",
session.getAttribute(notExistingName.toString()));
}
代码示例来源:origin: apache/jackrabbit
/** {@inheritDoc} */
public Object getAttribute(String name) throws RemoteException {
return session.getAttribute(name);
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if getAttribute(String name) returns not null if the requested
* attribute is existing
*/
public void testGetAttribute() throws NotExecutableException {
String names[] = session.getAttributeNames();
if (names.length == 0) {
throw new NotExecutableException("No attributes set in this session.");
}
for (int i = 0; i < names.length; i++) {
assertNotNull("getAttribute(String name) returned null although the " +
"requested attribute is existing.",
session.getAttribute(names[i]));
}
}
代码示例来源:origin: net.adamcin.oakpal/oakpal-core
@Override
public Object getAttribute(String name) {
return delegate.getAttribute(name);
}
代码示例来源:origin: org.apache.sling/org.apache.sling.launchpad.test-services
assertEquals("Expect 3 session attributes", 3,
s.getAttributeNames().length);
assertEquals("AStringValue", s.getAttribute("testAttributeString"));
assertEquals(999, s.getAttribute("testAttributeNumber"));
assertEquals("admin", s.getAttribute(ResourceResolverFactory.USER));
assertNull(session.getAttribute(ResourceResolverFactory.PASSWORD));
代码示例来源:origin: apache/jackrabbit
/**
* @return the specified session attribute
*/
public Object getSessionAttribute(String name) {
return eventState.getSession().getAttribute(name);
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void loginWithAttribute() throws RepositoryException {
Session session = ((JackrabbitRepository) getRepository()).login(
new GuestCredentials(), null,
Collections.<String, Object>singletonMap(RepositoryImpl.REFRESH_INTERVAL, 42));
String[] attributeNames = session.getAttributeNames();
assertEquals(1, attributeNames.length);
assertEquals(RepositoryImpl.REFRESH_INTERVAL, attributeNames[0]);
assertEquals(42L, session.getAttribute(RepositoryImpl.REFRESH_INTERVAL));
session.logout();
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core
/**
* @return the specified session attribute
*/
public Object getSessionAttribute(String name) {
return eventState.getSession().getAttribute(name);
}
代码示例来源:origin: apache/jackrabbit
/**
* JCR-1932: Session.getAttributes( ) call always returns an empty array
*
* @see <a href="https://issues.apache.org/jira/browse/JCR-1932">JCR-1932</a>
*/
public void testSessionAttributes() throws RepositoryException {
SimpleCredentials credentials =
new SimpleCredentials("admin", "admin".toCharArray());
credentials.setAttribute("test", "attribute");
Session session = getHelper().getRepository().login(credentials);
try {
String[] names = session.getAttributeNames();
assertEquals(1, names.length);
assertEquals("test", names[0]);
assertEquals("attribute", session.getAttribute("test"));
} finally {
session.logout();
}
}
代码示例来源:origin: apache/jackrabbit
/**
* Return the attribute.
*/
public Object getAttribute(String name) {
return getSession().getAttribute(name);
}
代码示例来源:origin: apache/jackrabbit-oak
@Test
public void loginWithCredentialsAttribute() throws RepositoryException {
SimpleCredentials sc = getAdminCredentials();
sc.setAttribute("attr", "val");
Session session = null;
try {
session = getRepository().login(sc, null);
String[] attributeNames = session.getAttributeNames();
assertEquals(1, attributeNames.length);
assertEquals("attr", attributeNames[0]);
assertEquals("val", session.getAttribute("attr"));
} finally {
if (session != null) {
session.logout();
}
}
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jca
/**
* Return the attribute.
*/
public Object getAttribute(String name) {
return getSession().getAttribute(name);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Object getAttribute(String name) {
return getWrappedSession().getAttribute(name);
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
@Override
default Object getAttribute(final String name) {
return unwrapSession().getAttribute(name);
}
代码示例来源:origin: ModeShape/modeshape
@Override
public Object getAttribute( String name ) {
return session().getAttribute(name);
}
代码示例来源:origin: net.adamcin.commons/net.adamcin.commons.jcr
public Object getAttribute(String name)
{ return getSession().getAttribute(name); }
代码示例来源:origin: brix-cms/brix-cms
public Object getAttribute(String name) {
return getDelegate().getAttribute(name);
}
代码示例来源:origin: org.apache.sling/org.apache.sling.jcr.resource
@Override
public Object getAttribute(final @Nonnull ResolveContext<JcrProviderState> ctx, final @Nonnull String name) {
if (isAttributeVisible(name)) {
if (ResourceResolverFactory.USER.equals(name)) {
return ctx.getProviderState().getSession().getUserID();
}
return ctx.getProviderState().getSession().getAttribute(name);
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!